@@ -185,6 +185,160 @@ public interface FileOpenDialog111
185185 await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
186186 }
187187
188+ [ Fact ]
189+ public async Task TestInterfaceDeclarationDoesNotStartWithIWithConflictAsync ( )
190+ {
191+ string testCode = @"
192+ public interface Foo
193+ {
194+ }
195+
196+ public interface IFoo { }" ;
197+ string fixedCode = @"
198+ public interface IFoo1
199+ {
200+ }
201+
202+ public interface IFoo { }" ;
203+
204+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 2 , 18 ) ;
205+
206+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
207+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
208+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
209+ }
210+
211+ [ Fact ]
212+ public async Task TestInterfaceDeclarationDoesNotStartWithIWithMemberConflictAsync ( )
213+ {
214+ string testCode = @"
215+ public interface Foo
216+ {
217+ int IFoo { get; }
218+ }" ;
219+ string fixedCode = @"
220+ public interface IFoo1
221+ {
222+ int IFoo { get; }
223+ }" ;
224+
225+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 2 , 18 ) ;
226+
227+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
228+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
229+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
230+ }
231+
232+ [ Fact ]
233+ public async Task TestNestedInterfaceDeclarationDoesNotStartWithIWithConflictAsync ( )
234+ {
235+ string testCode = @"
236+ public class Outer
237+ {
238+ public interface Foo
239+ {
240+ }
241+
242+ public interface IFoo { }
243+ }" ;
244+ string fixedCode = @"
245+ public class Outer
246+ {
247+ public interface IFoo1
248+ {
249+ }
250+
251+ public interface IFoo { }
252+ }" ;
253+
254+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 4 , 22 ) ;
255+
256+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
257+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
258+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
259+ }
260+
261+ [ Fact ]
262+ public async Task TestNestedInterfaceDeclarationDoesNotStartWithIWithContainingTypeConflictAsync ( )
263+ {
264+ string testCode = @"
265+ public class IFoo
266+ {
267+ public interface Foo
268+ {
269+ }
270+ }" ;
271+ string fixedCode = @"
272+ public class IFoo
273+ {
274+ public interface IFoo1
275+ {
276+ }
277+ }" ;
278+
279+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 4 , 22 ) ;
280+
281+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
282+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
283+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
284+ }
285+
286+ [ Fact ]
287+ public async Task TestNestedInterfaceDeclarationDoesNotStartWithIWithNonInterfaceConflictAsync ( )
288+ {
289+ string testCode = @"
290+ public class Outer
291+ {
292+ public interface Foo
293+ {
294+ }
295+
296+ private int IFoo => 0;
297+ }" ;
298+ string fixedCode = @"
299+ public class Outer
300+ {
301+ public interface IFoo1
302+ {
303+ }
304+
305+ private int IFoo => 0;
306+ }" ;
307+
308+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 4 , 22 ) ;
309+
310+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
311+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
312+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
313+ }
314+
315+ [ Fact ]
316+ public async Task TestInterfaceDeclarationDoesNotStartWithIWithConflictInAnotherAssemblyAsync ( )
317+ {
318+ string testCode = @"
319+ namespace System
320+ {
321+ public interface Disposable
322+ {
323+ }
324+ }
325+ " ;
326+ string fixedCode = @"
327+ namespace System
328+ {
329+ public interface IDisposable1
330+ {
331+ }
332+ }
333+ " ;
334+
335+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 4 , 22 ) ;
336+
337+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
338+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
339+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
340+ }
341+
188342 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
189343 {
190344 yield return new SA1302InterfaceNamesMustBeginWithI ( ) ;
0 commit comments