@@ -185,6 +185,18 @@ public class ClassName
185
185
await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
186
186
}
187
187
188
+ [ Fact ]
189
+ [ WorkItem ( 3150 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150" ) ]
190
+ public async Task TestClassWithIncludedMissingDocumentationAsync ( )
191
+ {
192
+ var testCode = @"
193
+ /// <include file='MissingFile.xml' path='/ClassName/*' />
194
+ public class ClassName
195
+ {
196
+ }" ;
197
+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
198
+ }
199
+
188
200
[ Fact ]
189
201
public async Task TestClassWithIncludedSummaryDocumentationAsync ( )
190
202
{
@@ -210,6 +222,35 @@ public class ClassName
210
222
await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
211
223
}
212
224
225
+ [ Fact ]
226
+ [ WorkItem ( 3150 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150" ) ]
227
+ public async Task TestFieldWithIncludedSummaryDocumentationAsync ( )
228
+ {
229
+ var testCode = @"
230
+ public class ClassName
231
+ {
232
+ /// <include file='FieldWithSummary.xml' path='/FieldName/*' />
233
+ public int FieldName;
234
+ }" ;
235
+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
236
+ }
237
+
238
+ [ Fact ]
239
+ [ WorkItem ( 3150 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150" ) ]
240
+ public async Task TestFieldWithIncludedDefaultSummaryDocumentationAsync ( )
241
+ {
242
+ var testCode = @"
243
+ public class ClassName
244
+ {
245
+ /// <include file='FieldWithDefaultSummary.xml' path='/FieldName/*' />
246
+ public {|#0:int FieldName|};
247
+ }" ;
248
+
249
+ DiagnosticResult expected = Diagnostic ( ) . WithLocation ( 0 ) ;
250
+
251
+ await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
252
+ }
253
+
213
254
private static Task VerifyCSharpDiagnosticAsync ( string source , DiagnosticResult expected , CancellationToken cancellationToken )
214
255
=> VerifyCSharpDiagnosticAsync ( source , new [ ] { expected } , cancellationToken ) ;
215
256
@@ -232,6 +273,20 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[
232
273
Summary description for the ClassName class.
233
274
</summary>
234
275
</ClassName>
276
+ " ;
277
+ string fieldContentWithSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
278
+ <FieldName>
279
+ <summary>
280
+ Foo
281
+ </summary>
282
+ </FieldName>
283
+ " ;
284
+ string fieldContentWithDefaultSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
285
+ <FieldName>
286
+ <summary>
287
+ Summary description for the ClassName class.
288
+ </summary>
289
+ </FieldName>
235
290
" ;
236
291
237
292
var test = new StyleCopDiagnosticVerifier < SA1608ElementDocumentationMustNotHaveDefaultSummary > . CSharpTest
@@ -242,6 +297,8 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[
242
297
{ "ClassWithoutSummary.xml" , contentWithoutSummary } ,
243
298
{ "ClassWithSummary.xml" , contentWithSummary } ,
244
299
{ "ClassWithDefaultSummary.xml" , contentWithDefaultSummary } ,
300
+ { "FieldWithSummary.xml" , fieldContentWithSummary } ,
301
+ { "FieldWithDefaultSummary.xml" , fieldContentWithDefaultSummary } ,
245
302
} ,
246
303
} ;
247
304
0 commit comments