Skip to content

Commit c16da77

Browse files
Updated PropertySummaryDocumentationAnalyzer to prepare for the correct code fix for a public property with a private getter and summary which starts with "Gets".
1 parent 813d47e commit c16da77

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
@@ -199,6 +199,7 @@ public int Property
199199
[InlineData("public", "int", "{ set {} }", "Gets", "Sets")] // Regression test for #2253
200200
[InlineData("public", "int", "{ set {} }", "Gets or sets", "Sets")] // Regression test for #2253
201201
[InlineData("public", "int", "{ get; private set; }", "Sets", "Gets")] // Regression test for #2253
202+
[InlineData("public", "int", "{ private get; set; }", "Gets", "Sets")] // Regression test for #2253
202203
public async Task IncorrectSummaryTagWithKnownPrefixShouldBeFixedCorrectlyAsync(string accessibility, string type, string accessors, string summaryPrefix, string expectedArgument)
203204
{
204205
var testCode = $@"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
305305
else
306306
{
307307
diagnosticProperties.Add(ExpectedTextKey, startingTextSets);
308+
309+
if (prefixIsGets)
310+
{
311+
diagnosticProperties.Add(TextToRemoveKey, text.Substring(0, startingTextGets.Length));
312+
}
313+
308314
context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), startingTextSets));
309315
}
310316
}

0 commit comments

Comments
 (0)