|
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | 4 |
|
5 | 5 | using System.Collections.Immutable; |
| 6 | +using System.Linq; |
6 | 7 | using Microsoft.CodeAnalysis.CodeStyle; |
7 | 8 | using Microsoft.CodeAnalysis.Diagnostics; |
8 | 9 | using Microsoft.CodeAnalysis.EmbeddedLanguages.VirtualChars; |
@@ -63,18 +64,16 @@ private void AnalyzeInterpolation(OperationAnalysisContext context) |
63 | 64 | return; |
64 | 65 | } |
65 | 66 |
|
66 | | - var locations = ImmutableArray.Create(interpolation.Syntax.GetLocation()); |
| 67 | + context.ReportDiagnostic(DiagnosticHelper.Create( |
| 68 | + UnnecessaryWithSuggestionDescriptor, |
| 69 | + unnecessaryLocations.First(), |
| 70 | + option.Notification.Severity, |
| 71 | + additionalLocations: ImmutableArray.Create(interpolation.Syntax.GetLocation()), |
| 72 | + properties: null)); |
67 | 73 |
|
68 | | - var severity = option.Notification.Severity; |
69 | | - |
70 | | - for (var i = 0; i < unnecessaryLocations.Length; i++) |
| 74 | + foreach (var subsequentLocation in unnecessaryLocations.Skip(1)) |
71 | 75 | { |
72 | | - context.ReportDiagnostic(DiagnosticHelper.Create( |
73 | | - i == 0 ? UnnecessaryWithSuggestionDescriptor : UnnecessaryWithoutSuggestionDescriptor, |
74 | | - unnecessaryLocations[i], |
75 | | - severity, |
76 | | - additionalLocations: locations, |
77 | | - properties: null)); |
| 76 | + context.ReportDiagnostic(Diagnostic.Create(UnnecessaryWithoutSuggestionDescriptor, subsequentLocation)); |
78 | 77 | } |
79 | 78 | } |
80 | 79 | } |
|
0 commit comments