@@ -6,6 +6,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules
66 using System . Collections . Generic ;
77 using System . Threading ;
88 using System . Threading . Tasks ;
9+ using Helpers ;
10+ using Microsoft . CodeAnalysis ;
911 using Microsoft . CodeAnalysis . Diagnostics ;
1012 using StyleCop . Analyzers . DocumentationRules ;
1113 using TestHelper ;
@@ -290,6 +292,175 @@ public void Test() { }
290292 await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
291293 }
292294
295+ [ Fact ]
296+ public async Task TestIncludedDocumentationWithoutSummaryOrContentAsync ( )
297+ {
298+ var testCode = @"
299+ /// <summary>
300+ /// Foo
301+ /// </summary>
302+ public partial class ClassName
303+ {
304+ /// <include file='MethodWithoutSummaryOrContent.xml' path='/ClassName/Test/*'/>
305+ partial void Test();
306+ }" ;
307+
308+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
309+ }
310+
311+ [ Fact ]
312+ public async Task TestIncludedDocumentationWithEmptySummaryAsync ( )
313+ {
314+ var testCode = @"
315+ /// <summary>
316+ /// Foo
317+ /// </summary>
318+ public partial class ClassName
319+ {
320+ /// <include file='MethodWithEmptySummary.xml' path='/ClassName/Test/*'/>
321+ partial void Test();
322+ }" ;
323+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 18 ) ;
324+
325+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
326+ }
327+
328+ [ Fact ]
329+ public async Task TestIncludedDocumentationWithEmptyContentAsync ( )
330+ {
331+ var testCode = @"
332+ /// <summary>
333+ /// Foo
334+ /// </summary>
335+ public partial class ClassName
336+ {
337+ /// <include file='MethodWithEmptyContent.xml' path='/ClassName/Test/*'/>
338+ partial void Test();
339+ }" ;
340+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 18 ) ;
341+
342+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
343+ }
344+
345+ [ Fact ]
346+ public async Task TestIncludedDocumentationWithInheritdocAsync ( )
347+ {
348+ var testCode = @"
349+ /// <summary>
350+ /// Foo
351+ /// </summary>
352+ public partial class ClassName
353+ {
354+ /// <include file='MethodWithInheritdoc.xml' path='/ClassName/Test/*'/>
355+ partial void Test();
356+ }" ;
357+
358+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
359+ }
360+
361+ [ Fact ]
362+ public async Task TestIncludedDocumentationWithSummaryAsync ( )
363+ {
364+ var testCode = @"
365+ /// <summary>
366+ /// Foo
367+ /// </summary>
368+ public partial class ClassName
369+ {
370+ /// <include file='MethodWithSummary.xml' path='/ClassName/Test/*'/>
371+ partial void Test();
372+ }" ;
373+
374+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
375+ }
376+
377+ [ Fact ]
378+ public async Task TestIncludedDocumentationWithContentAsync ( )
379+ {
380+ var testCode = @"
381+ /// <summary>
382+ /// Foo
383+ /// </summary>
384+ public partial class ClassName
385+ {
386+ /// <include file='MethodWithContent.xml' path='/ClassName/Test/*'/>
387+ partial void Test();
388+ }" ;
389+
390+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
391+ }
392+
393+ /// <inheritdoc/>
394+ protected override Project ApplyCompilationOptions ( Project project )
395+ {
396+ var resolver = new TestXmlReferenceResolver ( ) ;
397+
398+ string contentWithoutSummaryOrContent = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
399+ <ClassName>
400+ <Test>
401+ </Test>
402+ </ClassName>
403+ " ;
404+ resolver . XmlReferences . Add ( "MethodWithoutSummaryOrContent.xml" , contentWithoutSummaryOrContent ) ;
405+
406+ string contentWithEmptySummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
407+ <ClassName>
408+ <Test>
409+ <summary>
410+
411+ </summary>
412+ </Test>
413+ </ClassName>
414+ " ;
415+ resolver . XmlReferences . Add ( "MethodWithEmptySummary.xml" , contentWithEmptySummary ) ;
416+
417+ string contentWithEmptyContent = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
418+ <ClassName>
419+ <Test>
420+ <content>
421+
422+ </content>
423+ </Test>
424+ </ClassName>
425+ " ;
426+ resolver . XmlReferences . Add ( "MethodWithEmptyContent.xml" , contentWithEmptyContent ) ;
427+
428+ string contentWithInheritdoc = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
429+ <ClassName>
430+ <Test>
431+ <inheritdoc/>
432+ </Test>
433+ </ClassName>
434+ " ;
435+ resolver . XmlReferences . Add ( "MethodWithInheritdoc.xml" , contentWithInheritdoc ) ;
436+
437+ string contentWithSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
438+ <ClassName>
439+ <Test>
440+ <summary>
441+ Foo
442+ </summary>
443+ </Test>
444+ </ClassName>
445+ " ;
446+ resolver . XmlReferences . Add ( "MethodWithSummary.xml" , contentWithSummary ) ;
447+
448+ string contentWithContent = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
449+ <ClassName>
450+ <Test>
451+ <content>
452+ Foo
453+ </content>
454+ </Test>
455+ </ClassName>
456+ " ;
457+ resolver . XmlReferences . Add ( "MethodWithContent.xml" , contentWithContent ) ;
458+
459+ project = base . ApplyCompilationOptions ( project ) ;
460+ project = project . WithCompilationOptions ( project . CompilationOptions . WithXmlReferenceResolver ( resolver ) ) ;
461+ return project ;
462+ }
463+
293464 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
294465 {
295466 yield return new SA1607PartialElementDocumentationMustHaveSummaryText ( ) ;
0 commit comments