@@ -219,6 +219,102 @@ public async Task TestStaticConstructorMissingDocumentationGenericAsync(string t
219219 await this . TestConstructorMissingDocumentationAsync ( typeKind , "static" , StaticConstructorStandardText , $ " { typeKind } .", true ) . ConfigureAwait ( false ) ;
220220 }
221221
222+ [ Theory ]
223+ [ InlineData ( "class" ) ]
224+ [ InlineData ( "struct" ) ]
225+ public async Task TestNonPrivateConstructorSimpleDocumentationAsync ( string typeKind )
226+ {
227+ await this . TestConstructorSimpleDocumentationAsync ( typeKind , "public" , NonPrivateConstructorStandardText , $ " { typeKind } ", false ) . ConfigureAwait ( false ) ;
228+ }
229+
230+ [ Theory ]
231+ [ InlineData ( "class" ) ]
232+ [ InlineData ( "struct" ) ]
233+ public async Task TestNonPrivateConstructorSimpleDocumentationGenericAsync ( string typeKind )
234+ {
235+ await this . TestConstructorSimpleDocumentationAsync ( typeKind , "public" , NonPrivateConstructorStandardText , $ " { typeKind } ", true ) . ConfigureAwait ( false ) ;
236+ }
237+
238+ [ Theory ]
239+ [ InlineData ( "class" ) ]
240+ [ InlineData ( "struct" ) ]
241+ public async Task TestPrivateConstructorSimpleDocumentationAsync ( string typeKind )
242+ {
243+ await this . TestConstructorSimpleDocumentationAsync ( typeKind , "private" , NonPrivateConstructorStandardText , $ " { typeKind } ", false ) . ConfigureAwait ( false ) ;
244+ }
245+
246+ [ Theory ]
247+ [ InlineData ( "class" ) ]
248+ [ InlineData ( "struct" ) ]
249+ public async Task TestPrivateConstructorSimpleDocumentationGenericAsync ( string typeKind )
250+ {
251+ await this . TestConstructorSimpleDocumentationAsync ( typeKind , "private" , NonPrivateConstructorStandardText , $ " { typeKind } ", true ) . ConfigureAwait ( false ) ;
252+ }
253+
254+ [ Theory ]
255+ [ InlineData ( "class" ) ]
256+ [ InlineData ( "struct" ) ]
257+ public async Task TestStaticConstructorSimpleDocumentationAsync ( string typeKind )
258+ {
259+ await this . TestConstructorSimpleDocumentationAsync ( typeKind , "static" , StaticConstructorStandardText , $ " { typeKind } .", false ) . ConfigureAwait ( false ) ;
260+ }
261+
262+ [ Theory ]
263+ [ InlineData ( "class" ) ]
264+ [ InlineData ( "struct" ) ]
265+ public async Task TestStaticConstructorSimpleDocumentationGenericAsync ( string typeKind )
266+ {
267+ await this . TestConstructorSimpleDocumentationAsync ( typeKind , "static" , StaticConstructorStandardText , $ " { typeKind } .", true ) . ConfigureAwait ( false ) ;
268+ }
269+
270+ [ Theory ]
271+ [ InlineData ( "class" ) ]
272+ [ InlineData ( "struct" ) ]
273+ public async Task TestNonPrivateConstructorSimpleDocumentationWrongTypeNameAsync ( string typeKind )
274+ {
275+ await this . TestConstructorSimpleDocumentationWrongTypeNameAsync ( typeKind , "public" , NonPrivateConstructorStandardText , $ " { typeKind } ", false ) . ConfigureAwait ( false ) ;
276+ }
277+
278+ [ Theory ]
279+ [ InlineData ( "class" ) ]
280+ [ InlineData ( "struct" ) ]
281+ public async Task TestNonPrivateConstructorSimpleDocumentationGenericWrongTypeNameAsync ( string typeKind )
282+ {
283+ await this . TestConstructorSimpleDocumentationWrongTypeNameAsync ( typeKind , "public" , NonPrivateConstructorStandardText , $ " { typeKind } ", true ) . ConfigureAwait ( false ) ;
284+ }
285+
286+ [ Theory ]
287+ [ InlineData ( "class" ) ]
288+ [ InlineData ( "struct" ) ]
289+ public async Task TestPrivateConstructorSimpleDocumentationWrongTypeNameAsync ( string typeKind )
290+ {
291+ await this . TestConstructorSimpleDocumentationWrongTypeNameAsync ( typeKind , "private" , NonPrivateConstructorStandardText , $ " { typeKind } ", false ) . ConfigureAwait ( false ) ;
292+ }
293+
294+ [ Theory ]
295+ [ InlineData ( "class" ) ]
296+ [ InlineData ( "struct" ) ]
297+ public async Task TestPrivateConstructorSimpleDocumentationGenericWrongTypeNameAsync ( string typeKind )
298+ {
299+ await this . TestConstructorSimpleDocumentationWrongTypeNameAsync ( typeKind , "private" , NonPrivateConstructorStandardText , $ " { typeKind } ", true ) . ConfigureAwait ( false ) ;
300+ }
301+
302+ [ Theory ]
303+ [ InlineData ( "class" ) ]
304+ [ InlineData ( "struct" ) ]
305+ public async Task TestStaticConstructorSimpleDocumentationWrongTypeNameAsync ( string typeKind )
306+ {
307+ await this . TestConstructorSimpleDocumentationWrongTypeNameAsync ( typeKind , "static" , StaticConstructorStandardText , $ " { typeKind } .", false ) . ConfigureAwait ( false ) ;
308+ }
309+
310+ [ Theory ]
311+ [ InlineData ( "class" ) ]
312+ [ InlineData ( "struct" ) ]
313+ public async Task TestStaticConstructorSimpleDocumentationGenericWrongTypeNameAsync ( string typeKind )
314+ {
315+ await this . TestConstructorSimpleDocumentationWrongTypeNameAsync ( typeKind , "static" , StaticConstructorStandardText , $ " { typeKind } .", true ) . ConfigureAwait ( false ) ;
316+ }
317+
222318 /// <summary>
223319 /// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#676 "SA1642 misfires on nested structs,
224320 /// requiring text describing the outer type"
@@ -315,15 +411,14 @@ internal abstract class CustomizableBlockSubscriberBase<TSource, TTarget, TSubsc
315411{
316412 /// <summary>
317413 /// Initializes a new instance of the <see cref=""CustomizableBlockSubscriberBase{TSource, TTarget, TSubscribedElement}""/> class.
318- /// Initializes a new instance of the <see cref=""ProjectBuildSnapshotService""/> class.
319414 /// </summary>
320415 protected CustomizableBlockSubscriberBase()
321416 {
322417 }
323418}
324419" ;
325420
326- DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 6 , 9 ) ;
421+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 7 , 43 ) ;
327422 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
328423 await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
329424 await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -470,5 +565,97 @@ await this.VerifyCSharpDiagnosticAsync(
470565 fixedCode = string . Format ( fixedCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
471566 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
472567 }
568+
569+ private async Task TestConstructorSimpleDocumentationAsync ( string typeKind , string modifiers , string part1 , string part2 , bool generic )
570+ {
571+ string part3 = part2 . EndsWith ( "." ) ? string . Empty : "." ;
572+
573+ var testCode = @"namespace FooNamespace
574+ {{
575+ public {0} Foo{1}
576+ {{
577+ /// <summary>
578+ /// {3}Foo{4}{5}
579+ /// </summary>
580+ {6}
581+ Foo({7})
582+ {{
583+
584+ }}
585+ }}
586+ }}" ;
587+ string arguments = typeKind == "struct" && modifiers != "static" ? "int argument" : null ;
588+ testCode = string . Format ( testCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
589+
590+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 5 , 13 ) ;
591+
592+ await this . VerifyCSharpDiagnosticAsync (
593+ testCode ,
594+ expected ,
595+ CancellationToken . None ) . ConfigureAwait ( false ) ;
596+
597+ var fixedCode = @"namespace FooNamespace
598+ {{
599+ public {0} Foo{1}
600+ {{
601+ /// <summary>
602+ /// {3}<see cref=""Foo{2}""/>{4}{5}
603+ /// </summary>
604+ {6}
605+ Foo({7})
606+ {{
607+
608+ }}
609+ }}
610+ }}" ;
611+ fixedCode = string . Format ( fixedCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
612+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
613+ }
614+
615+ private async Task TestConstructorSimpleDocumentationWrongTypeNameAsync ( string typeKind , string modifiers , string part1 , string part2 , bool generic )
616+ {
617+ string part3 = part2 . EndsWith ( "." ) ? string . Empty : "." ;
618+
619+ var testCode = @"namespace FooNamespace
620+ {{
621+ public {0} Foo{1}
622+ {{
623+ /// <summary>
624+ /// {3}Bar{4}{5}
625+ /// </summary>
626+ {6}
627+ Foo({7})
628+ {{
629+
630+ }}
631+ }}
632+ }}" ;
633+ string arguments = typeKind == "struct" && modifiers != "static" ? "int argument" : null ;
634+ testCode = string . Format ( testCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
635+
636+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 5 , 13 ) ;
637+
638+ await this . VerifyCSharpDiagnosticAsync (
639+ testCode ,
640+ expected ,
641+ CancellationToken . None ) . ConfigureAwait ( false ) ;
642+
643+ var fixedCode = @"namespace FooNamespace
644+ {{
645+ public {0} Foo{1}
646+ {{
647+ /// <summary>
648+ /// {3}<see cref=""Foo{2}""/>{4}{5}
649+ /// </summary>
650+ {6}
651+ Foo({7})
652+ {{
653+
654+ }}
655+ }}
656+ }}" ;
657+ fixedCode = string . Format ( fixedCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
658+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
659+ }
473660 }
474661}
0 commit comments