@@ -81,6 +81,77 @@ public class TestClass
8181 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
8282 }
8383
84+ /// <summary>
85+ /// Verifies that property documentation that does not start with the appropriate text will result in a
86+ /// diagnostic. This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#1844.
87+ /// </summary>
88+ /// <param name="accessibility">The accessibility of the property.</param>
89+ /// <param name="type">The type to use for the property.</param>
90+ /// <param name="accessors">The accessors for the property.</param>
91+ /// <param name="expectedArgument">The expected argument for the diagnostic message.</param>
92+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
93+ [ Theory ]
94+ [ InlineData ( "public" , "int" , "{ get; set; }" , "Gets or sets" ) ]
95+ [ InlineData ( "public" , "int" , "{ get; protected set; }" , "Gets or sets" ) ]
96+ [ InlineData ( "public" , "int" , "{ get; protected internal set; }" , "Gets or sets" ) ]
97+ [ InlineData ( "public" , "int" , "{ get; internal set; }" , "Gets or sets" ) ]
98+ [ InlineData ( "public" , "int" , "{ get; private set; }" , "Gets" ) ]
99+ [ InlineData ( "public" , "int" , "{ get; }" , "Gets" ) ]
100+ [ InlineData ( "public" , "int" , "{ get; } = 0;" , "Gets" ) ]
101+ [ InlineData ( "public" , "int" , "=> 0;" , "Gets" ) ]
102+ [ InlineData ( "public" , "int" , "{ set { } }" , "Sets" ) ]
103+ [ InlineData ( "public" , "int" , "{ internal get { return 0; } set { } }" , "Gets or sets" ) ]
104+ [ InlineData ( "public" , "int" , "{ private get { return 0; } set { } }" , "Sets" ) ]
105+ [ InlineData ( "public" , "bool" , "{ get; set; }" , "Gets or sets a value indicating whether" ) ]
106+ [ InlineData ( "public" , "bool" , "{ get; }" , "Gets a value indicating whether" ) ]
107+ [ InlineData ( "public" , "bool" , "{ get; } = true;" , "Gets a value indicating whether" ) ]
108+ [ InlineData ( "public" , "bool" , "=> true;" , "Gets a value indicating whether" ) ]
109+ [ InlineData ( "public" , "bool" , "{ get; private set; }" , "Gets a value indicating whether" ) ]
110+ [ InlineData ( "public" , "bool" , "{ set { } }" , "Sets a value indicating whether" ) ]
111+ [ InlineData ( "public" , "bool" , "{ private get { return false; } set { } }" , "Sets a value indicating whether" ) ]
112+ [ InlineData ( "protected" , "int" , "{ get; private set; }" , "Gets" ) ]
113+ [ InlineData ( "protected" , "int" , "{ private get { return 0; } set { } }" , "Sets" ) ]
114+ [ InlineData ( "protected internal" , "int" , "{ get; internal set; }" , "Gets or sets" ) ]
115+ [ InlineData ( "protected internal" , "int" , "{ get; private set; }" , "Gets" ) ]
116+ [ InlineData ( "protected internal" , "int" , "{ internal get { return 0; } set { } }" , "Gets or sets" ) ]
117+ [ InlineData ( "protected internal" , "int" , "{ private get { return 0; } set { } }" , "Sets" ) ]
118+ [ InlineData ( "internal" , "int" , "{ get; private set; }" , "Gets" ) ]
119+ [ InlineData ( "internal" , "int" , "{ private get { return 0; } set { } }" , "Sets" ) ]
120+ public async Task VerifyDocumentationOfPublicMethodInPrivateClassWillProduceDiagnosticAsync ( string accessibility , string type , string accessors , string expectedArgument )
121+ {
122+ var testCode = $@ "
123+ public class TestClass
124+ {{
125+ private class PrivateTestClass
126+ {{
127+ /// <summary>
128+ /// The first test value.
129+ /// </summary>
130+ { accessibility } { type } TestProperty { accessors }
131+ }}
132+ }}
133+ " ;
134+
135+ var fixedTestCode = $@ "
136+ public class TestClass
137+ {{
138+ private class PrivateTestClass
139+ {{
140+ /// <summary>
141+ /// { expectedArgument } the first test value.
142+ /// </summary>
143+ { accessibility } { type } TestProperty { accessors }
144+ }}
145+ }}
146+ " ;
147+
148+ var expected = this . CSharpDiagnostic ( PropertySummaryDocumentationAnalyzer . SA1623Descriptor ) . WithLocation ( 9 , 11 + accessibility . Length + type . Length ) . WithArguments ( expectedArgument ) ;
149+
150+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
151+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
152+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
153+ }
154+
84155 /// <inheritdoc/>
85156 protected override CodeFixProvider GetCSharpCodeFixProvider ( )
86157 {
0 commit comments