Skip to content

Commit 813d47e

Browse files
Updated PropertySummaryDocumentationAnalyzer to prepare for the correct code fix for a public property with a private setter and summary which starts with "Sets".
1 parent 526c7d3 commit 813d47e

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1623UnitTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public int Property
198198
[InlineData("internal", "int", "=> 0;", "Gets or sets", "Gets")] // Regression test for #2253
199199
[InlineData("public", "int", "{ set {} }", "Gets", "Sets")] // Regression test for #2253
200200
[InlineData("public", "int", "{ set {} }", "Gets or sets", "Sets")] // Regression test for #2253
201+
[InlineData("public", "int", "{ get; private set; }", "Sets", "Gets")] // Regression test for #2253
201202
public async Task IncorrectSummaryTagWithKnownPrefixShouldBeFixedCorrectlyAsync(string accessibility, string type, string accessors, string summaryPrefix, string expectedArgument)
202203
{
203204
var testCode = $@"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
259259
else
260260
{
261261
diagnosticProperties.Add(ExpectedTextKey, startingTextGets);
262+
263+
if (prefixIsSets)
264+
{
265+
diagnosticProperties.Add(TextToRemoveKey, text.Substring(0, startingTextSets.Length));
266+
}
267+
262268
context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), startingTextGets));
263269
}
264270
}

0 commit comments

Comments
 (0)