Skip to content

Commit 02cb0ec

Browse files
committed
Add regression tests for #1818
1 parent 90708ec commit 02cb0ec

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1208UnitTests.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ class A
160160

161161
DiagnosticResult[] expected =
162162
{
163-
this.CSharpDiagnostic().WithLocation("Test3.cs", 2, 1).WithArguments("global::System.IO", "global::AnotherNamespace"),
164163
this.CSharpDiagnostic().WithLocation("Test3.cs", 8, 5).WithArguments("System.Threading", "Xyz"),
165-
this.CSharpDiagnostic().WithLocation("Test3.cs", 9, 5).WithArguments("global::System", "Xyz")
166164
};
167165

168166
await this.VerifyCSharpDiagnosticAsync(sources, expected, CancellationToken.None).ConfigureAwait(false);
@@ -336,6 +334,31 @@ public async Task TestPreprocessorDirectivesAsync()
336334
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
337335
}
338336

337+
/// <summary>
338+
/// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#1818.
339+
/// </summary>
340+
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
341+
[Fact]
342+
public async Task TestValidUsingDirectivesWithGlobalAliasAsync()
343+
{
344+
var testCode = @"
345+
namespace Foo
346+
{
347+
extern alias corlib;
348+
using System;
349+
using System.Threading;
350+
using corlib::System;
351+
using Foo;
352+
using global::Foo;
353+
using global::System;
354+
using global::System.IO;
355+
using global::System.Linq;
356+
using Microsoft;
357+
}";
358+
359+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
360+
}
361+
339362
/// <inheritdoc/>
340363
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
341364
{

StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210UnitTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public async Task TestInvalidOrderedUsingDirectivesWithNamespaceAliasQualifierAs
182182
using global::System;
183183
using global::Foo;
184184
using Foo;
185+
using Microsoft;
185186
186187
namespace Foo
187188
{
@@ -200,6 +201,7 @@ namespace Foo
200201
using global::System;
201202
using global::System.IO;
202203
using global::System.Linq;
204+
using Microsoft;
203205
}";
204206

205207
DiagnosticResult[] expected =

0 commit comments

Comments
 (0)