@@ -5,35 +5,66 @@ namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules
55{
66 using System . Threading ;
77 using System . Threading . Tasks ;
8+ using Microsoft . CodeAnalysis ;
9+ using Microsoft . CodeAnalysis . CSharp ;
810 using StyleCop . Analyzers . Test . OrderingRules ;
911 using TestHelper ;
1012 using Xunit ;
1113
1214 public class SA1206CSharp7UnitTests : SA1206UnitTests
1315 {
14- [ Fact ( Skip = "The version of the compiler used in these tests does not yet support this feature." ) ]
16+ [ Fact ]
1517 public async Task TestRefKeywordInStructDeclarationAsync ( )
1618 {
17- var testCode = @"private ref struct BitHelper
19+ var testCode = @"class OuterClass
1820{
21+ private ref struct BitHelper
22+ {
23+ }
24+ }
25+ " ;
26+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
27+ }
28+
29+ [ Fact ]
30+ public async Task TestReadonlyKeywordInStructDeclarationAsync ( )
31+ {
32+ var testCode = @"class OuterClass
33+ {
34+ private readonly struct BitHelper
35+ {
36+ }
1937}
2038" ;
2139 await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
2240 }
2341
24- [ Fact ( Skip = "The version of the compiler used in these tests does not yet support this feature." ) ]
25- public async Task TestRefKeywordInStructDeclarationWrongOrderAsync ( )
42+ [ Fact ]
43+ public async Task TestReadonlyKeywordInStructDeclarationWrongOrderAsync ( )
2644 {
27- var testCode = @"ref private struct BitHelper
45+ // Note that we don't need a test for ref with the wrong order, because this would be a compile time error
46+ var testCode = @"class OuterClass
2847{
48+ readonly private struct BitHelper
49+ {
50+ }
2951}
3052" ;
3153
3254 DiagnosticResult [ ] expected = new [ ]
3355 {
34- this . CSharpDiagnostic ( ) . WithLocation ( 1 , 13 ) . WithArguments ( "ref " , "private " ) ,
56+ this . CSharpDiagnostic ( ) . WithLocation ( 3 , 14 ) . WithArguments ( "private " , "readonly " ) ,
3557 } ;
3658 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
3759 }
60+
61+ protected override Project ApplyCompilationOptions ( Project project )
62+ {
63+ var newProject = base . ApplyCompilationOptions ( project ) ;
64+
65+ var parseOptions = ( CSharpParseOptions ) newProject . ParseOptions ;
66+
67+ return newProject . WithParseOptions ( parseOptions . WithLanguageVersion ( LanguageVersion . Latest ) ) ;
68+ }
3869 }
3970}
0 commit comments