33
44namespace StyleCop . Analyzers . Test . DocumentationRules
55{
6- using System ;
76 using System . Collections . Generic ;
8- using System . Linq ;
97 using System . Threading ;
108 using System . Threading . Tasks ;
119 using Microsoft . CodeAnalysis ;
@@ -27,7 +25,7 @@ public async Task TestDocumentationAsync()
2725 var testCode = @"
2826/// <summary>
2927/// Test class
30- /// <summary>
28+ /// </ summary>
3129public class TestClass
3230{
3331 /// <summary>
@@ -89,7 +87,7 @@ public int TestMethod2<T>(T arg1)
8987 var fixedTestCode = @"
9088/// <summary>
9189/// Test class.
92- /// <summary>
90+ /// </ summary>
9391public class TestClass
9492{
9593 /// <summary>
@@ -184,7 +182,7 @@ public async Task TestAugmentedInheritedDocumentationAsync()
184182 var testCode = @"
185183/// <summary>
186184/// Test interface.
187- /// <summary>
185+ /// </ summary>
188186public interface ITest
189187{
190188 /// <summary>Test method.</summary>
@@ -196,7 +194,7 @@ public interface ITest
196194
197195/// <summary>
198196/// Test class.
199- /// <summary>
197+ /// </ summary>
200198public class TestClass : ITest
201199{
202200 /// <inheritdoc/>
@@ -214,7 +212,7 @@ public int TestMethod<T>(T arg1)
214212 var fixedTestCode = @"
215213/// <summary>
216214/// Test interface.
217- /// <summary>
215+ /// </ summary>
218216public interface ITest
219217{
220218 /// <summary>Test method.</summary>
@@ -226,7 +224,7 @@ public interface ITest
226224
227225/// <summary>
228226/// Test class.
229- /// <summary>
227+ /// </ summary>
230228public class TestClass : ITest
231229{
232230 /// <inheritdoc/>
@@ -297,6 +295,160 @@ public class TestClass
297295 await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
298296 }
299297
298+ [ Fact ]
299+ [ WorkItem ( 2680 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2680" ) ]
300+ public async Task TestReportingAfterEmptyElementAsync ( )
301+ {
302+ var testCode = @"
303+ /// <summary>
304+ /// Test interface <see cref=""ITest""/>
305+ /// </summary>
306+ public interface ITest
307+ {
308+ /// <summary>
309+ /// Test method <see cref=""Method""/>
310+ /// </summary>
311+ void Method();
312+ }
313+ " ;
314+
315+ var fixedTestCode = @"
316+ /// <summary>
317+ /// Test interface <see cref=""ITest""/>.
318+ /// </summary>
319+ public interface ITest
320+ {
321+ /// <summary>
322+ /// Test method <see cref=""Method""/>.
323+ /// </summary>
324+ void Method();
325+ }
326+ " ;
327+
328+ DiagnosticResult [ ] expected =
329+ {
330+ this . CSharpDiagnostic ( ) . WithLocation ( 3 , 39 ) ,
331+ this . CSharpDiagnostic ( ) . WithLocation ( 8 , 41 ) ,
332+ } ;
333+
334+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
335+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
336+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
337+ }
338+
339+ [ Fact ]
340+ [ WorkItem ( 2680 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2680" ) ]
341+ public async Task TestReportingAfterTwoEmptyElementsAsync ( )
342+ {
343+ var testCode = @"
344+ /// <summary>
345+ /// Test interface <see cref=""ITest""/> <see cref=""ITest""/>
346+ /// </summary>
347+ public interface ITest
348+ {
349+ /// <summary>
350+ /// Test method <see cref=""Method""/><see cref=""Method""/>
351+ /// </summary>
352+ void Method();
353+ }
354+ " ;
355+
356+ var fixedTestCode = @"
357+ /// <summary>
358+ /// Test interface <see cref=""ITest""/> <see cref=""ITest""/>.
359+ /// </summary>
360+ public interface ITest
361+ {
362+ /// <summary>
363+ /// Test method <see cref=""Method""/><see cref=""Method""/>.
364+ /// </summary>
365+ void Method();
366+ }
367+ " ;
368+
369+ DiagnosticResult [ ] expected =
370+ {
371+ this . CSharpDiagnostic ( ) . WithLocation ( 3 , 59 ) ,
372+ this . CSharpDiagnostic ( ) . WithLocation ( 8 , 61 ) ,
373+ } ;
374+
375+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
376+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
377+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
378+ }
379+
380+ [ Fact ]
381+ [ WorkItem ( 2680 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2680" ) ]
382+ public async Task TestReportingAfterEmptyElementTwoSentencesAsync ( )
383+ {
384+ var testCode = @"
385+ /// <summary>
386+ /// Test interface. <see cref=""ITest""/>
387+ /// </summary>
388+ public interface ITest
389+ {
390+ /// <summary>
391+ /// Test method. <see cref=""Method""/><see cref=""Method""/>
392+ /// </summary>
393+ void Method();
394+ }
395+ " ;
396+
397+ var fixedTestCode = @"
398+ /// <summary>
399+ /// Test interface. <see cref=""ITest""/>.
400+ /// </summary>
401+ public interface ITest
402+ {
403+ /// <summary>
404+ /// Test method. <see cref=""Method""/><see cref=""Method""/>.
405+ /// </summary>
406+ void Method();
407+ }
408+ " ;
409+
410+ DiagnosticResult [ ] expected =
411+ {
412+ this . CSharpDiagnostic ( ) . WithLocation ( 3 , 40 ) ,
413+ this . CSharpDiagnostic ( ) . WithLocation ( 8 , 62 ) ,
414+ } ;
415+
416+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
417+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
418+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
419+ }
420+
421+ [ Fact ]
422+ [ WorkItem ( 2679 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2679" ) ]
423+ public async Task TestElementsThatDoNotRequirePeriodsAsync ( )
424+ {
425+ var testCode = @"
426+ /// <summary>
427+ /// Test interface <see cref=""ITest"">a see element</see>
428+ /// </summary>
429+ /// <seealso href=""https://docs.microsoft.com/en-us/dotnet/framework/wpf/index"">Windows Presentation Foundation</seealso>
430+ public interface ITest
431+ {
432+ }
433+ " ;
434+
435+ var fixedTestCode = @"
436+ /// <summary>
437+ /// Test interface <see cref=""ITest"">a see element</see>.
438+ /// </summary>
439+ /// <seealso href=""https://docs.microsoft.com/en-us/dotnet/framework/wpf/index"">Windows Presentation Foundation</seealso>
440+ public interface ITest
441+ {
442+ }
443+ " ;
444+
445+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 3 , 57 ) ;
446+
447+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
448+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
449+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
450+ }
451+
300452 protected override Project ApplyCompilationOptions ( Project project )
301453 {
302454 var resolver = new TestXmlReferenceResolver ( ) ;
0 commit comments