Skip to content

Commit 3d6cf93

Browse files
authored
Merge pull request #2821 from sharwell/wrapping-tests
Add tests for wrapped using alias directives
2 parents 3c31e20 + 4a14eca commit 3d6cf93

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1135UnitTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,44 @@ namespace Test {
230230

231231
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
232232
}
233+
234+
[Fact]
235+
public async Task TestFullyQualifiedAliasWithWrappedTypeArgumentsAsync()
236+
{
237+
var testCode = @"
238+
using Example = System.ValueTuple<
239+
System.Int32,
240+
System.Int32>;
241+
";
242+
243+
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
244+
}
245+
246+
[Fact(Skip = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2820")]
247+
[WorkItem(2820, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2820")]
248+
public async Task TestAliasWithWrappedTypeArgumentsInsideNamespaceAsync()
249+
{
250+
var testCode = @"
251+
using System;
252+
253+
namespace Test {
254+
using Example = System.ValueTuple<
255+
Exception,
256+
Exception>;
257+
}
258+
";
259+
var fixedCode = @"
260+
using System;
261+
262+
namespace Test {
263+
using Example = System.ValueTuple<
264+
System.Exception,
265+
System.Exception>;
266+
}
267+
";
268+
269+
var expected = Diagnostic(SA1135UsingDirectivesMustBeQualified.DescriptorType).WithLocation(5, 5).WithArguments("System.ValueTuple<System.Exception, System.Exception>");
270+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
271+
}
233272
}
234273
}

0 commit comments

Comments
 (0)