Skip to content

Commit 56fa929

Browse files
committed
Add test cases for unmanaged keywork
1 parent 00b9141 commit 56fa929

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1023CSharp9UnitTests.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
55
{
66
using System.Threading;
77
using System.Threading.Tasks;
8+
using Microsoft.CodeAnalysis.CSharp;
89
using Microsoft.CodeAnalysis.Testing;
910
using StyleCop.Analyzers.Test.CSharp8.SpacingRules;
11+
using StyleCop.Analyzers.Test.Verifiers;
1012
using Xunit;
1113
using static StyleCop.Analyzers.SpacingRules.SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly;
1214
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
@@ -38,7 +40,7 @@ public async Task TestFunctionPointerParameterInvalidSpacingAsync()
3840
Diagnostic(DescriptorNotFollowed).WithLocation(1),
3941
};
4042

41-
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
43+
await VerifyCSharpFixAsync(LanguageVersion.CSharp9, testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
4244
}
4345

4446
[Fact]
@@ -50,6 +52,8 @@ public async Task TestFunctionPointerTypeInvalidSpacingAsync()
5052
unsafe delegate{|#1:*|} <int*> FuncPtr2;
5153
unsafe delegate {|#2:*|} managed<int*> FuncPtr3;
5254
unsafe delegate{|#3:*|}managed<int*> FuncPtr4;
55+
unsafe delegate {|#4:*|} unmanaged<int*> FuncPtr5;
56+
unsafe delegate{|#5:*|}unmanaged<int*> FuncPtr6;
5357
}
5458
";
5559

@@ -59,18 +63,26 @@ public async Task TestFunctionPointerTypeInvalidSpacingAsync()
5963
unsafe delegate*<int*> FuncPtr2;
6064
unsafe delegate* managed<int*> FuncPtr3;
6165
unsafe delegate* managed<int*> FuncPtr4;
66+
unsafe delegate* unmanaged<int*> FuncPtr5;
67+
unsafe delegate* unmanaged<int*> FuncPtr6;
6268
}
6369
";
6470

65-
var expected = new[]
71+
await new CSharpTest(LanguageVersion.CSharp9)
6672
{
67-
Diagnostic(DescriptorNotPreceded).WithLocation(0),
68-
Diagnostic(DescriptorNotFollowed).WithLocation(1),
69-
Diagnostic(DescriptorNotPreceded).WithLocation(2),
70-
Diagnostic(DescriptorFollowed).WithLocation(3),
71-
};
72-
73-
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
73+
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50,
74+
TestCode = testCode,
75+
FixedCode = fixedCode,
76+
ExpectedDiagnostics =
77+
{
78+
Diagnostic(DescriptorNotPreceded).WithLocation(0),
79+
Diagnostic(DescriptorNotFollowed).WithLocation(1),
80+
Diagnostic(DescriptorNotPreceded).WithLocation(2),
81+
Diagnostic(DescriptorFollowed).WithLocation(3),
82+
Diagnostic(DescriptorNotPreceded).WithLocation(4),
83+
Diagnostic(DescriptorFollowed).WithLocation(5),
84+
},
85+
}.RunAsync().ConfigureAwait(false);
7486
}
7587
}
7688
}

0 commit comments

Comments
 (0)