@@ -115,6 +115,92 @@ class A
115115 await this . VerifyCSharpDiagnosticAsync ( usingsInNamespaceDeclaration , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
116116 }
117117
118+ [ Fact ]
119+ public async Task TestWhenSystemAndWindowsUsingDirectivesAreNotOnTopInCompilationAsync ( )
120+ {
121+ var usingsInCompilationUnit = new [ ]
122+ {
123+ "namespace Windows.Foundation {}" ,
124+ "namespace Xyz {}" ,
125+ "namespace AnotherNamespace {}" ,
126+ @"using Xyz;
127+ using System;
128+ using System.IO;
129+ using AnotherNamespace;
130+ using Windows.Foundation;
131+ using System.Threading.Tasks;
132+
133+ class A
134+ {
135+ }" ,
136+ } ;
137+
138+ DiagnosticResult [ ] expected =
139+ {
140+ this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 2 , 1 ) . WithArguments ( "System" , "Xyz" ) ,
141+ this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 3 , 1 ) . WithArguments ( "System.IO" , "Xyz" ) ,
142+ this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 5 , 1 ) . WithArguments ( "Windows.Foundation" , "Xyz" ) ,
143+ this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 6 , 1 ) . WithArguments ( "System.Threading.Tasks" , "Xyz" ) ,
144+ } ;
145+
146+ await this . VerifyCSharpDiagnosticAsync ( usingsInCompilationUnit , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
147+ }
148+
149+ [ Fact ]
150+ public async Task TestWhenSystemAndWindowsUsingDirectivesAreNotOnTopInNamespaceAsync ( )
151+ {
152+ var usingsInNamespaceDeclaration = new [ ]
153+ {
154+ "namespace Windows.Foundation {}" ,
155+ "namespace Namespace {}" ,
156+ "namespace AnotherNamespace {}" ,
157+ @"namespace Test
158+ {
159+ using Namespace;
160+ using System.Threading;
161+ using System.IO;
162+ using Windows.Foundation;
163+ using AnotherNamespace;
164+
165+ class A
166+ {
167+ }
168+ }" ,
169+ } ;
170+
171+ DiagnosticResult [ ] expected =
172+ {
173+ this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 4 , 5 ) . WithArguments ( "System.Threading" , "Namespace" ) ,
174+ this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 5 , 5 ) . WithArguments ( "System.IO" , "Namespace" ) ,
175+ this . CSharpDiagnostic ( ) . WithLocation ( "Test3.cs" , 6 , 5 ) . WithArguments ( "Windows.Foundation" , "Namespace" ) ,
176+ } ;
177+
178+ await this . VerifyCSharpDiagnosticAsync ( usingsInNamespaceDeclaration , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
179+ }
180+
181+ [ Fact ]
182+ public async Task TestWhenWindowsUsingDirectivesAreNotOnTopAsync ( )
183+ {
184+ var usingsInCompilationUnit = new [ ]
185+ {
186+ "namespace Windows.Foundation {}" ,
187+ "namespace Namespace {}" ,
188+ @"using Namespace;
189+ using Windows.Foundation;
190+
191+ class A
192+ {
193+ }" ,
194+ } ;
195+
196+ DiagnosticResult [ ] expected =
197+ {
198+ this . CSharpDiagnostic ( ) . WithLocation ( "Test2.cs" , 2 , 1 ) . WithArguments ( "Windows.Foundation" , "Namespace" ) ,
199+ } ;
200+
201+ await this . VerifyCSharpDiagnosticAsync ( usingsInCompilationUnit , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
202+ }
203+
118204 [ Fact ]
119205 public async Task TestSystemUsingDirectivesInCompilationUnitAndInNamespaceDeclarationAsync ( )
120206 {
0 commit comments