Skip to content

Commit 2579be4

Browse files
committed
Update SA1121 tests for function pointers
1 parent d9999d9 commit 2579be4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1121CSharp9UnitTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,45 @@
33

44
namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
68
using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules;
9+
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
11+
StyleCop.Analyzers.ReadabilityRules.SA1121UseBuiltInTypeAlias,
12+
StyleCop.Analyzers.ReadabilityRules.SA1121CodeFixProvider>;
713

814
public partial class SA1121CSharp9UnitTests : SA1121CSharp8UnitTests
915
{
16+
[Fact]
17+
[WorkItem(3970, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3970")]
18+
public async Task TestFunctionPointerParametersAsync()
19+
{
20+
var testCode = @"using System;
21+
public class TestClass
22+
{
23+
private unsafe delegate*<{|#0:System.Int64|}, {|#1:System.Int32|}> field1;
24+
private unsafe delegate*<{|#2:Int64|}, {|#3:Int32|}> field2;
25+
}
26+
";
27+
28+
var fixedCode = @"using System;
29+
public class TestClass
30+
{
31+
private unsafe delegate*<long, int> field1;
32+
private unsafe delegate*<long, int> field2;
33+
}
34+
";
35+
36+
var expected = new[]
37+
{
38+
Diagnostic().WithLocation(0),
39+
Diagnostic().WithLocation(1),
40+
Diagnostic().WithLocation(2),
41+
Diagnostic().WithLocation(3),
42+
};
43+
44+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
45+
}
1046
}
1147
}

0 commit comments

Comments
 (0)