@@ -617,6 +617,135 @@ public void TestMethod3() { }
617617 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
618618 }
619619
620+ /// <summary>
621+ /// Verifies that enum member declarations with invalid documentation will produce the expected diagnostics.
622+ /// </summary>
623+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
624+ [ Fact ]
625+ public async Task TestInvalidEnumMemberDeclarationsAsync ( )
626+ {
627+ var testCode = @"namespace TestNamespace
628+ {
629+ public enum TestEnum
630+ {
631+ /// <summary>
632+ /// This is an enum member.
633+ /// </summary>
634+
635+ Foo = 0
636+ }
637+ }
638+ " ;
639+
640+ var fixedTestCode = @"namespace TestNamespace
641+ {
642+ public enum TestEnum
643+ {
644+ /// <summary>
645+ /// This is an enum member.
646+ /// </summary>
647+ Foo = 0
648+ }
649+ }
650+ " ;
651+
652+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 1 ) ;
653+
654+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None ) . ConfigureAwait ( false ) ;
655+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
656+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
657+ }
658+
659+ /// <summary>
660+ /// Verifies that operator declarations with invalid documentation will produce the expected diagnostics.
661+ /// </summary>
662+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
663+ [ Fact ]
664+ public async Task TestInvalidOperatorDeclarationsAsync ( )
665+ {
666+ var testCode = @"namespace TestNamespace
667+ {
668+ public struct Foo
669+ {
670+ /// <summary>
671+ /// This is an operator declaration.
672+ /// </summary>
673+
674+ public static Foo operator +(Foo x, Foo y)
675+ {
676+ return new Foo();
677+ }
678+ }
679+ }
680+ " ;
681+
682+ var fixedTestCode = @"namespace TestNamespace
683+ {
684+ public struct Foo
685+ {
686+ /// <summary>
687+ /// This is an operator declaration.
688+ /// </summary>
689+ public static Foo operator +(Foo x, Foo y)
690+ {
691+ return new Foo();
692+ }
693+ }
694+ }
695+ " ;
696+
697+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 1 ) ;
698+
699+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None ) . ConfigureAwait ( false ) ;
700+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
701+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
702+ }
703+
704+ /// <summary>
705+ /// Verifies that conversion operator declarations with invalid documentation will produce the expected diagnostics.
706+ /// </summary>
707+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
708+ [ Fact ]
709+ public async Task TestInvalidConversionOperatorDeclarationsAsync ( )
710+ {
711+ var testCode = @"namespace TestNamespace
712+ {
713+ public struct Foo
714+ {
715+ /// <summary>
716+ /// This is a conversion operator declaration.
717+ /// </summary>
718+
719+ public static explicit operator Foo(string s)
720+ {
721+ return new Foo();
722+ }
723+ }
724+ }
725+ " ;
726+
727+ var fixedTestCode = @"namespace TestNamespace
728+ {
729+ public struct Foo
730+ {
731+ /// <summary>
732+ /// This is a conversion operator declaration.
733+ /// </summary>
734+ public static explicit operator Foo(string s)
735+ {
736+ return new Foo();
737+ }
738+ }
739+ }
740+ " ;
741+
742+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 1 ) ;
743+
744+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None ) . ConfigureAwait ( false ) ;
745+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
746+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
747+ }
748+
620749 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
621750 {
622751 yield return new SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine ( ) ;
0 commit comments