Skip to content

Commit da058c4

Browse files
committed
refactor diagnostics reporting
1 parent 330fd7b commit da058c4

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertySummaryDocumentationAnalyzer.cs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,32 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
216216
}
217217
}
218218

219-
if (getterVisible && !setterVisible)
219+
if (getterVisible)
220220
{
221-
if (startsWithGetOrSet)
221+
if (setterVisible)
222222
{
223-
diagnosticProperties.Add(ExpectedTextKey, startingTextGets);
224-
diagnosticProperties.Add(TextToRemoveKey, startingTextGetsOrSets);
225-
context.ReportDiagnostic(Diagnostic.Create(SA1624Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), "get", startingTextGets));
223+
if (!startsWithGetOrSet)
224+
{
225+
diagnosticProperties.Add(ExpectedTextKey, startingTextGetsOrSets);
226+
context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), startingTextGetsOrSets));
227+
}
226228
}
227-
else if (!text.StartsWith(startingTextGets, StringComparison.Ordinal))
229+
else
228230
{
229-
diagnosticProperties.Add(ExpectedTextKey, startingTextGets);
230-
context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), startingTextGets));
231+
if (startsWithGetOrSet)
232+
{
233+
diagnosticProperties.Add(ExpectedTextKey, startingTextGets);
234+
diagnosticProperties.Add(TextToRemoveKey, startingTextGetsOrSets);
235+
context.ReportDiagnostic(Diagnostic.Create(SA1624Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), "get", startingTextGets));
236+
}
237+
else if (!text.StartsWith(startingTextGets, StringComparison.Ordinal))
238+
{
239+
diagnosticProperties.Add(ExpectedTextKey, startingTextGets);
240+
context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), startingTextGets));
241+
}
231242
}
232243
}
233-
else if (!getterVisible && setterVisible)
244+
else if (setterVisible)
234245
{
235246
if (startsWithGetOrSet)
236247
{
@@ -244,14 +255,6 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
244255
context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), startingTextSets));
245256
}
246257
}
247-
else
248-
{
249-
if (!startsWithGetOrSet)
250-
{
251-
diagnosticProperties.Add(ExpectedTextKey, startingTextGetsOrSets);
252-
context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), startingTextGetsOrSets));
253-
}
254-
}
255258
}
256259
}
257260
}

0 commit comments

Comments
 (0)