@@ -282,16 +282,39 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml
282282 }
283283 else if ( setterVisible )
284284 {
285- if ( startsWithGetsOrSets )
285+ if ( getter != null )
286286 {
287- diagnosticProperties . Add ( ExpectedTextKey , startingTextSets ) ;
288- diagnosticProperties . Add ( TextToRemoveKey , startingTextGetsOrSets ) ;
289- context . ReportDiagnostic ( Diagnostic . Create ( SA1624Descriptor , diagnosticLocation , diagnosticProperties . ToImmutable ( ) , "set" , startingTextSets ) ) ;
287+ // Both getter and setter exist, but only setter is visible
288+ if ( startsWithGetsOrSets )
289+ {
290+ diagnosticProperties . Add ( ExpectedTextKey , startingTextSets ) ;
291+ diagnosticProperties . Add ( TextToRemoveKey , startingTextGetsOrSets ) ;
292+ context . ReportDiagnostic ( Diagnostic . Create ( SA1624Descriptor , diagnosticLocation , diagnosticProperties . ToImmutable ( ) , "set" , startingTextSets ) ) ;
293+ }
294+ else if ( ! startsWithSets )
295+ {
296+ diagnosticProperties . Add ( ExpectedTextKey , startingTextSets ) ;
297+ context . ReportDiagnostic ( Diagnostic . Create ( SA1623Descriptor , diagnosticLocation , diagnosticProperties . ToImmutable ( ) , startingTextSets ) ) ;
298+ }
290299 }
291- else if ( ! startsWithSets )
300+ else
292301 {
293- diagnosticProperties . Add ( ExpectedTextKey , startingTextSets ) ;
294- context . ReportDiagnostic ( Diagnostic . Create ( SA1623Descriptor , diagnosticLocation , diagnosticProperties . ToImmutable ( ) , startingTextSets ) ) ;
302+ // Setter exists and is visible. Getter does not exist.
303+ if ( ! startsWithSets )
304+ {
305+ diagnosticProperties . Add ( ExpectedTextKey , startingTextSets ) ;
306+
307+ if ( startsWithGetsOrSets )
308+ {
309+ diagnosticProperties . Add ( TextToRemoveKey , text . Substring ( 0 , startingTextGetsOrSets . Length ) ) ;
310+ }
311+ else if ( startsWithGets )
312+ {
313+ diagnosticProperties . Add ( TextToRemoveKey , text . Substring ( 0 , startingTextGets . Length ) ) ;
314+ }
315+
316+ context . ReportDiagnostic ( Diagnostic . Create ( SA1623Descriptor , diagnosticLocation , diagnosticProperties . ToImmutable ( ) , startingTextSets ) ) ;
317+ }
295318 }
296319 }
297320 }
0 commit comments