Skip to content

Commit

Permalink
Improve coverage for SA1110 by adding tests for attributes with quali…
Browse files Browse the repository at this point in the history
…fied names
  • Loading branch information
bjornhellander committed Jul 1, 2023
1 parent 7885adb commit 92d66c6
Showing 1 changed file with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,31 +603,33 @@ public void Bar()
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestAttributeOpeningParenthesisOnTheNextLineAsync()
[Theory]
[InlineData("Conditional")]
[InlineData("System.Diagnostics.Conditional")]
public async Task TestAttributeOpeningParenthesisOnTheNextLineAsync(string attributeName)
{
var testCode = @"
var testCode = $@"
using System.Diagnostics;
public class Foo
{
[Conditional
(""DEBUG""), Conditional
{{
[{attributeName}
(""DEBUG""), {attributeName}
(""TEST1"")]
public void Baz()
{
}
}";
var fixedCode = @"
{{
}}
}}";
var fixedCode = $@"
using System.Diagnostics;
public class Foo
{
[Conditional(
""DEBUG""), Conditional(
{{
[{attributeName}(
""DEBUG""), {attributeName}(
""TEST1"")]
public void Baz()
{
}
}";
{{
}}
}}";

DiagnosticResult[] expected =
{
Expand All @@ -638,19 +640,21 @@ public void Baz()
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestAttributeOpeningParenthesisOnTheSameLineAsync()
[Theory]
[InlineData("Conditional")]
[InlineData("System.Diagnostics.Conditional")]
public async Task TestAttributeOpeningParenthesisOnTheSameLineAsync(string attributeName)
{
var testCode = @"
var testCode = $@"
using System.Diagnostics;
public class Foo
{
[Conditional(""DEBUG""), Conditional(""TEST1"")]
{{
[{attributeName}(""DEBUG""), {attributeName}(""TEST1"")]
public void Baz()
{
{{
}
}";
}}
}}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
Expand Down

0 comments on commit 92d66c6

Please sign in to comment.