@@ -75,7 +75,8 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool
7575 propertyDeclaration ,
7676 resourceManager . GetString ( nameof ( DocumentationResources . StartingTextGetsWhether ) , culture ) ,
7777 resourceManager . GetString ( nameof ( DocumentationResources . StartingTextSetsWhether ) , culture ) ,
78- resourceManager . GetString ( nameof ( DocumentationResources . StartingTextGetsOrSetsWhether ) , culture ) ) ;
78+ resourceManager . GetString ( nameof ( DocumentationResources . StartingTextGetsOrSetsWhether ) , culture ) ,
79+ resourceManager . GetString ( nameof ( DocumentationResources . StartingTextReturnsWhether ) , culture ) ) ;
7980 }
8081 else
8182 {
@@ -86,11 +87,12 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool
8687 propertyDeclaration ,
8788 resourceManager . GetString ( nameof ( DocumentationResources . StartingTextGets ) , culture ) ,
8889 resourceManager . GetString ( nameof ( DocumentationResources . StartingTextSets ) , culture ) ,
89- resourceManager . GetString ( nameof ( DocumentationResources . StartingTextGetsOrSets ) , culture ) ) ;
90+ resourceManager . GetString ( nameof ( DocumentationResources . StartingTextGetsOrSets ) , culture ) ,
91+ resourceManager . GetString ( nameof ( DocumentationResources . StartingTextReturns ) , culture ) ) ;
9092 }
9193 }
9294
93- private static void AnalyzeSummaryElement ( SyntaxNodeAnalysisContext context , XmlNodeSyntax syntax , Location diagnosticLocation , PropertyDeclarationSyntax propertyDeclaration , string startingTextGets , string startingTextSets , string startingTextGetsOrSets )
95+ private static void AnalyzeSummaryElement ( SyntaxNodeAnalysisContext context , XmlNodeSyntax syntax , Location diagnosticLocation , PropertyDeclarationSyntax propertyDeclaration , string startingTextGets , string startingTextSets , string startingTextGetsOrSets , string startingTextReturns )
9496 {
9597 var diagnosticProperties = ImmutableDictionary . CreateBuilder < string , string > ( ) ;
9698 ArrowExpressionClauseSyntax expressionBody = propertyDeclaration . ExpressionBody ;
@@ -133,6 +135,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
133135 bool prefixIsGetsOrSets = text . StartsWith ( startingTextGetsOrSets , StringComparison . OrdinalIgnoreCase ) ;
134136 bool prefixIsGets = ! prefixIsGetsOrSets && text . StartsWith ( startingTextGets , StringComparison . OrdinalIgnoreCase ) ;
135137 bool prefixIsSets = text . StartsWith ( startingTextSets , StringComparison . OrdinalIgnoreCase ) ;
138+ bool prefixIsReturns = text . StartsWith ( startingTextReturns , StringComparison . OrdinalIgnoreCase ) ;
136139
137140 bool getterVisible , setterVisible ;
138141 if ( getter != null && setter != null )
@@ -227,7 +230,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
227230 // Both getter and setter are visible.
228231 if ( ! prefixIsGetsOrSets )
229232 {
230- ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextGetsOrSets , unexpectedStartingText1 : startingTextGets , unexpectedStartingText2 : startingTextSets ) ;
233+ ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextGetsOrSets , unexpectedStartingText1 : startingTextGets , unexpectedStartingText2 : startingTextSets , unexpectedStartingText3 : startingTextReturns ) ;
231234 }
232235 }
233236 else if ( setter != null )
@@ -241,7 +244,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
241244 }
242245 else
243246 {
244- ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextGets , unexpectedStartingText1 : startingTextSets ) ;
247+ ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextGets , unexpectedStartingText1 : startingTextSets , unexpectedStartingText2 : startingTextReturns ) ;
245248 }
246249 }
247250 }
@@ -250,7 +253,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
250253 // Getter exists and is visible. Setter does not exist.
251254 if ( ! prefixIsGets )
252255 {
253- ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextGets , unexpectedStartingText1 : startingTextSets , unexpectedStartingText2 : startingTextGetsOrSets ) ;
256+ ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextGets , unexpectedStartingText1 : startingTextSets , unexpectedStartingText2 : startingTextGetsOrSets , unexpectedStartingText3 : startingTextReturns ) ;
254257 }
255258 }
256259 }
@@ -267,7 +270,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
267270 }
268271 else
269272 {
270- ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextSets , unexpectedStartingText1 : startingTextGets ) ;
273+ ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextSets , unexpectedStartingText1 : startingTextGets , unexpectedStartingText2 : startingTextReturns ) ;
271274 }
272275 }
273276 }
@@ -276,13 +279,13 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
276279 // Setter exists and is visible. Getter does not exist.
277280 if ( ! prefixIsSets )
278281 {
279- ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextSets , unexpectedStartingText1 : startingTextGetsOrSets , unexpectedStartingText2 : startingTextGets ) ;
282+ ReportSA1623 ( context , diagnosticLocation , diagnosticProperties , text , expectedStartingText : startingTextSets , unexpectedStartingText1 : startingTextGetsOrSets , unexpectedStartingText2 : startingTextGets , unexpectedStartingText3 : startingTextReturns ) ;
280283 }
281284 }
282285 }
283286 }
284287
285- private static void ReportSA1623 ( SyntaxNodeAnalysisContext context , Location diagnosticLocation , ImmutableDictionary < string , string > . Builder diagnosticProperties , string text , string expectedStartingText , string unexpectedStartingText1 , string unexpectedStartingText2 = null )
288+ private static void ReportSA1623 ( SyntaxNodeAnalysisContext context , Location diagnosticLocation , ImmutableDictionary < string , string > . Builder diagnosticProperties , string text , string expectedStartingText , string unexpectedStartingText1 , string unexpectedStartingText2 = null , string unexpectedStartingText3 = null )
286289 {
287290 diagnosticProperties . Add ( ExpectedTextKey , expectedStartingText ) ;
288291
@@ -294,6 +297,10 @@ private static void ReportSA1623(SyntaxNodeAnalysisContext context, Location dia
294297 {
295298 diagnosticProperties . Add ( TextToRemoveKey , text . Substring ( 0 , unexpectedStartingText2 . Length ) ) ;
296299 }
300+ else if ( ( unexpectedStartingText3 != null ) && text . StartsWith ( unexpectedStartingText3 , StringComparison . OrdinalIgnoreCase ) )
301+ {
302+ diagnosticProperties . Add ( TextToRemoveKey , text . Substring ( 0 , unexpectedStartingText3 . Length ) ) ;
303+ }
297304
298305 context . ReportDiagnostic ( Diagnostic . Create ( SA1623Descriptor , diagnosticLocation , diagnosticProperties . ToImmutable ( ) , expectedStartingText ) ) ;
299306 }
0 commit comments