@@ -6,6 +6,7 @@ namespace StyleCop.Analyzers.Test.SpacingRules
66 using System . Collections . Generic ;
77 using System . Threading ;
88 using System . Threading . Tasks ;
9+ using Microsoft . CodeAnalysis ;
910 using Microsoft . CodeAnalysis . CodeFixes ;
1011 using Microsoft . CodeAnalysis . Diagnostics ;
1112 using StyleCop . Analyzers . SpacingRules ;
@@ -836,6 +837,65 @@ public async Task TestGotoCaseStatementAsync()
836837 await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
837838 }
838839
840+ [ Fact ]
841+ public async Task TestMissingSelectTokenAsync ( )
842+ {
843+ string testCode = @"
844+ class ClassName
845+ {
846+ void MethodName()
847+ {
848+ var result = from x in new int[0];
849+ }
850+ }
851+ " ;
852+
853+ DiagnosticResult [ ] expected =
854+ {
855+ new DiagnosticResult
856+ {
857+ Id = "CS0742" ,
858+ Severity = DiagnosticSeverity . Error ,
859+ Message = "A query body must end with a select clause or a group clause" ,
860+ Locations = new [ ] { new DiagnosticResultLocation ( "Test0.cs" , 6 , 42 ) }
861+ }
862+ } ;
863+
864+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
865+ }
866+
867+ [ Fact ]
868+ public async Task TestTrailingCommentAsync ( )
869+ {
870+ string testCode = @"
871+ class ClassName
872+ {
873+ void MethodName()
874+ {
875+ if/*comment*/ (true)
876+ {
877+ }
878+ }
879+ }
880+ " ;
881+ string fixedCode = @"
882+ class ClassName
883+ {
884+ void MethodName()
885+ {
886+ if /*comment*/ (true)
887+ {
888+ }
889+ }
890+ }
891+ " ;
892+
893+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "if" , string . Empty , "followed" ) . WithLocation ( 6 , 9 ) ;
894+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
895+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
896+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
897+ }
898+
839899 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
840900 {
841901 yield return new SA1000KeywordsMustBeSpacedCorrectly ( ) ;
0 commit comments