@@ -617,6 +617,212 @@ public void TestMethod3() { }
617617 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
618618 }
619619
620+ /// <summary>
621+ /// Verifies that enum member declarations with valid (or no) documentation will not produce diagnostics.
622+ /// </summary>
623+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
624+ [ Fact ]
625+ public async Task TestValidEnumMemberDeclarationsAsync ( )
626+ {
627+ var testCode = @"namespace TestNamespace
628+ {
629+ public enum TestEnum
630+ {
631+ /// <summary>
632+ /// This is an enum member.
633+ /// </summary>
634+ Foo = 0,
635+ Bar = 1
636+ }
637+ }
638+ " ;
639+
640+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
641+ }
642+
643+ /// <summary>
644+ /// Verifies that enum member declarations with invalid documentation will produce the expected diagnostics.
645+ /// </summary>
646+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
647+ [ Fact ]
648+ public async Task TestInvalidEnumMemberDeclarationsAsync ( )
649+ {
650+ var testCode = @"namespace TestNamespace
651+ {
652+ public enum TestEnum
653+ {
654+ /// <summary>
655+ /// This is an enum member.
656+ /// </summary>
657+
658+ Foo = 0
659+ }
660+ }
661+ " ;
662+
663+ var fixedTestCode = @"namespace TestNamespace
664+ {
665+ public enum TestEnum
666+ {
667+ /// <summary>
668+ /// This is an enum member.
669+ /// </summary>
670+ Foo = 0
671+ }
672+ }
673+ " ;
674+
675+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 1 ) ;
676+
677+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None ) . ConfigureAwait ( false ) ;
678+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
679+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
680+ }
681+
682+ /// <summary>
683+ /// Verifies that operator declarations with valid (or no) documentation will not produce diagnostics.
684+ /// </summary>
685+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
686+ [ Fact ]
687+ public async Task TestValidOperatorDeclarationsAsync ( )
688+ {
689+ var testCode = @"namespace TestNamespace
690+ {
691+ public struct Foo
692+ {
693+ /// <summary>
694+ /// This is an operator declaration.
695+ /// </summary>
696+ public static Foo operator +(Foo x, Foo y)
697+ {
698+ return new Foo();
699+ }
700+
701+ private int testField1;
702+ }
703+ }
704+ " ;
705+
706+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
707+ }
708+
709+ /// <summary>
710+ /// Verifies that operator declarations with invalid documentation will produce the expected diagnostics.
711+ /// </summary>
712+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
713+ [ Fact ]
714+ public async Task TestInvalidOperatorDeclarationsAsync ( )
715+ {
716+ var testCode = @"namespace TestNamespace
717+ {
718+ public struct Foo
719+ {
720+ /// <summary>
721+ /// This is an operator declaration.
722+ /// </summary>
723+
724+ public static Foo operator +(Foo x, Foo y)
725+ {
726+ return new Foo();
727+ }
728+ }
729+ }
730+ " ;
731+
732+ var fixedTestCode = @"namespace TestNamespace
733+ {
734+ public struct Foo
735+ {
736+ /// <summary>
737+ /// This is an operator declaration.
738+ /// </summary>
739+ public static Foo operator +(Foo x, Foo y)
740+ {
741+ return new Foo();
742+ }
743+ }
744+ }
745+ " ;
746+
747+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 1 ) ;
748+
749+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None ) . ConfigureAwait ( false ) ;
750+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
751+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
752+ }
753+
754+ /// <summary>
755+ /// Verifies that conversion operator declarations with valid (or no) documentation will not produce diagnostics.
756+ /// </summary>
757+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
758+ [ Fact ]
759+ public async Task TestValidConversionOperatorDeclarationsAsync ( )
760+ {
761+ var testCode = @"namespace TestNamespace
762+ {
763+ public struct Foo
764+ {
765+ /// <summary>
766+ /// This is a conversion operator declaration.
767+ /// </summary>
768+ public static explicit operator Foo(string s)
769+ {
770+ return new Foo();
771+ }
772+
773+ private int testField1;
774+ }
775+ }
776+ " ;
777+
778+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
779+ }
780+
781+ /// <summary>
782+ /// Verifies that conversion operator declarations with invalid documentation will produce the expected diagnostics.
783+ /// </summary>
784+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
785+ [ Fact ]
786+ public async Task TestInvalidConversionOperatorDeclarationsAsync ( )
787+ {
788+ var testCode = @"namespace TestNamespace
789+ {
790+ public struct Foo
791+ {
792+ /// <summary>
793+ /// This is a conversion operator declaration.
794+ /// </summary>
795+
796+ public static explicit operator Foo(string s)
797+ {
798+ return new Foo();
799+ }
800+ }
801+ }
802+ " ;
803+
804+ var fixedTestCode = @"namespace TestNamespace
805+ {
806+ public struct Foo
807+ {
808+ /// <summary>
809+ /// This is a conversion operator declaration.
810+ /// </summary>
811+ public static explicit operator Foo(string s)
812+ {
813+ return new Foo();
814+ }
815+ }
816+ }
817+ " ;
818+
819+ var expectedDiagnostic = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 1 ) ;
820+
821+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostic , CancellationToken . None ) . ConfigureAwait ( false ) ;
822+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
823+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
824+ }
825+
620826 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
621827 {
622828 yield return new SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine ( ) ;
0 commit comments