@@ -44,6 +44,20 @@ class A
4444 await this . VerifyCSharpDiagnosticAsync ( usingsInNamespaceDeclaration , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
4545 }
4646
47+ [ Fact ]
48+ public async Task TestSystemUsingDirectivesWithEscapeSequenceAsync ( )
49+ {
50+ string usingsInNamespaceDeclaration = @"namespace Test
51+ {
52+ using @System;
53+ using System.Diagnostics;
54+ using \u0053ystem.IO;
55+ using System.Threading;
56+ }" ;
57+
58+ await this . VerifyCSharpDiagnosticAsync ( usingsInNamespaceDeclaration , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
59+ }
60+
4761 [ Fact ]
4862 public async Task TestWhenSystemUsingDirectivesAreNotOnTopInCompilationAsync ( )
4963 {
@@ -160,9 +174,7 @@ class A
160174
161175 DiagnosticResult [ ] expected =
162176 {
163- this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 2 , 1 ) . WithArguments ( "global::System.IO" , "global::AnotherNamespace" ) ,
164177 this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 8 , 5 ) . WithArguments ( "System.Threading" , "Xyz" ) ,
165- this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 9 , 5 ) . WithArguments ( "global::System" , "Xyz" )
166178 } ;
167179
168180 await this . VerifyCSharpDiagnosticAsync ( sources , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -336,6 +348,31 @@ public async Task TestPreprocessorDirectivesAsync()
336348 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
337349 }
338350
351+ /// <summary>
352+ /// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#1818.
353+ /// </summary>
354+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
355+ [ Fact ]
356+ public async Task TestValidUsingDirectivesWithGlobalAliasAsync ( )
357+ {
358+ var testCode = @"
359+ namespace Foo
360+ {
361+ extern alias corlib;
362+ using System;
363+ using System.Threading;
364+ using corlib::System;
365+ using Foo;
366+ using global::Foo;
367+ using global::System;
368+ using global::System.IO;
369+ using global::System.Linq;
370+ using Microsoft;
371+ }" ;
372+
373+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
374+ }
375+
339376 /// <inheritdoc/>
340377 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
341378 {
0 commit comments