@@ -305,6 +305,57 @@ public void TestMethod() { }
305305 await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
306306 }
307307
308+ /// <summary>
309+ /// Verifies that a delegate declaration that includes the inheritdoc will produce diagnostics.
310+ /// </summary>
311+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
312+ [ Fact ]
313+ [ WorkItem ( 3291 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3291" ) ]
314+ [ WorkItem ( 3291 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3291" ) ]
315+ public async Task TestIncorrectDocumentedDelegateInheritDocAsync ( )
316+ {
317+ var testCode = @"
318+ /// <summary>Foo</summary>
319+ /// <param name=""value"">some param</param>
320+ /// <returns>something</returns>
321+ public delegate bool TestDelegate(int value);
322+
323+ /// <summary>Test class</summary>
324+ public class TestClass
325+ {
326+ /// {|#0:<include file='DelegateInheritDoc.xml' path='/TestDelegate/*'/>|}
327+ public delegate bool TestDelegate(int value);
328+ }
329+ " ;
330+
331+ var expected = Diagnostic ( ) . WithLocation ( 0 ) ;
332+ await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
333+ }
334+
335+ /// <summary>
336+ /// Verifies that a delegate declaration that includes the inheritdoc will produce diagnostics.
337+ /// </summary>
338+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
339+ [ Fact ]
340+ [ WorkItem ( 3291 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3291" ) ]
341+ [ WorkItem ( 3291 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3291" ) ]
342+ public async Task TestIncorrectDelegateInheritDocAsync ( )
343+ {
344+ var testCode = @"
345+ public delegate bool TestDelegate(int value);
346+
347+ /// <summary>Test class</summary>
348+ public class TestClass
349+ {
350+ /// {|#0:<include file='DelegateInheritDoc.xml' path='/TestDelegate/*'/>|}
351+ public delegate bool TestDelegate(int value);
352+ }
353+ " ;
354+
355+ var expected = Diagnostic ( ) . WithLocation ( 0 ) ;
356+ await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
357+ }
358+
308359 private static Task VerifyCSharpDiagnosticAsync ( string source , DiagnosticResult expected , CancellationToken cancellationToken )
309360 => VerifyCSharpDiagnosticAsync ( source , new [ ] { expected } , cancellationToken ) ;
310361
@@ -329,6 +380,11 @@ private static StyleCopDiagnosticVerifier<SA1648InheritDocMustBeUsedWithInheriti
329380 <inheritdoc/>
330381 </TestMethod>
331382</TestClass>
383+ " ;
384+ string contentDelegateInheritDoc = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
385+ <TestDelegate>
386+ <inheritdoc/>
387+ </TestDelegate>
332388" ;
333389
334390 var test = new StyleCopDiagnosticVerifier < SA1648InheritDocMustBeUsedWithInheritingClass > . CSharpTest
@@ -337,6 +393,7 @@ private static StyleCopDiagnosticVerifier<SA1648InheritDocMustBeUsedWithInheriti
337393 {
338394 { "ClassInheritDoc.xml" , contentClassInheritDoc } ,
339395 { "MethodInheritDoc.xml" , contentMethodInheritDoc } ,
396+ { "DelegateInheritDoc.xml" , contentDelegateInheritDoc } ,
340397 } ,
341398 } ;
342399
0 commit comments