@@ -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"
@@ -470,5 +566,95 @@ await this.VerifyCSharpDiagnosticAsync(
470566 fixedCode = string . Format ( fixedCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
471567 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
472568 }
569+
570+ private async Task TestConstructorSimpleDocumentationAsync ( string typeKind , string modifiers , string part1 , string part2 , bool generic )
571+ {
572+ string part3 = part2 . EndsWith ( "." ) ? string . Empty : "." ;
573+
574+ var testCode = @"namespace FooNamespace
575+ {{
576+ public {0} Foo{1}
577+ {{
578+ /// <summary>
579+ /// {3}Foo{4}{5}
580+ /// </summary>
581+ {6}
582+ Foo({7})
583+ {{
584+
585+ }}
586+ }}
587+ }}" ;
588+ string arguments = typeKind == "struct" && modifiers != "static" ? "int argument" : null ;
589+ testCode = string . Format ( testCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
590+
591+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 5 , 13 ) ;
592+
593+ await this . VerifyCSharpDiagnosticAsync (
594+ testCode ,
595+ expected , 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 , CancellationToken . None ) . ConfigureAwait ( false ) ;
641+
642+ var fixedCode = @"namespace FooNamespace
643+ {{
644+ public {0} Foo{1}
645+ {{
646+ /// <summary>
647+ /// {3}<see cref=""Foo{2}""/>{4}{5}
648+ /// </summary>
649+ {6}
650+ Foo({7})
651+ {{
652+
653+ }}
654+ }}
655+ }}" ;
656+ fixedCode = string . Format ( fixedCode , typeKind , generic ? "<T1, T2>" : string . Empty , generic ? "{T1, T2}" : string . Empty , part1 , part2 , part3 , modifiers , arguments ) ;
657+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
658+ }
473659 }
474660}
0 commit comments