@@ -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 ;
@@ -288,6 +289,47 @@ public async Task TestClosingBracketFollowedBySpaceAndIncrementOrDecrementOperat
288289 await this . TestWhitespaceInStatementOrDeclAsync ( invalidStatament , fixedStatament , expected ) . ConfigureAwait ( false ) ;
289290 }
290291
292+ [ Fact ]
293+ public async Task TestMissingTokenAsync ( )
294+ {
295+ string testCode = @"
296+ class ClassName
297+ {
298+ void Method()
299+ {
300+ int[] x = new int[0;
301+ }
302+ }
303+ " ;
304+
305+ DiagnosticResult [ ] expected =
306+ {
307+ new DiagnosticResult
308+ {
309+ Id = "CS1003" ,
310+ Severity = DiagnosticSeverity . Error ,
311+ Message = "Syntax error, ',' expected" ,
312+ Locations = new [ ] { new DiagnosticResultLocation ( "Test0.cs" , 6 , 28 ) }
313+ } ,
314+ new DiagnosticResult
315+ {
316+ Id = "CS0443" ,
317+ Severity = DiagnosticSeverity . Error ,
318+ Message = "Syntax error; value expected" ,
319+ Locations = new [ ] { new DiagnosticResultLocation ( "Test0.cs" , 6 , 28 ) }
320+ } ,
321+ new DiagnosticResult
322+ {
323+ Id = "CS1003" ,
324+ Severity = DiagnosticSeverity . Error ,
325+ Message = "Syntax error, ']' expected" ,
326+ Locations = new [ ] { new DiagnosticResultLocation ( "Test0.cs" , 6 , 28 ) }
327+ }
328+ } ;
329+
330+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
331+ }
332+
291333 /// <inheritdoc/>
292334 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
293335 {
0 commit comments