@@ -6,6 +6,7 @@ namespace StyleCop.Analyzers.Test.OrderingRules
66 using System . Collections . Generic ;
77 using System . Threading ;
88 using System . Threading . Tasks ;
9+ using Microsoft . CodeAnalysis . CSharp ;
910 using Microsoft . CodeAnalysis . Testing ;
1011 using StyleCop . Analyzers . Lightup ;
1112 using StyleCop . Analyzers . OrderingRules ;
@@ -96,13 +97,21 @@ public static IEnumerable<object[]> ValidNestedDeclarations
9697 yield return new object [ ] { "protected internal" , "interface" } ;
9798 yield return new object [ ] { "private" , "interface" } ;
9899
100+ if ( LightupHelpers . SupportsCSharp72 )
101+ {
102+ yield return new object [ ] { "private protected" , "class" } ;
103+ yield return new object [ ] { "private protected" , "struct" } ;
104+ yield return new object [ ] { "private protected" , "interface" } ;
105+ }
106+
99107 if ( LightupHelpers . SupportsCSharp9 )
100108 {
101109 yield return new object [ ] { "public" , "record" } ;
102110 yield return new object [ ] { "protected" , "record" } ;
103111 yield return new object [ ] { "internal" , "record" } ;
104112 yield return new object [ ] { "protected internal" , "record" } ;
105113 yield return new object [ ] { "private" , "record" } ;
114+ yield return new object [ ] { "private protected" , "record" } ;
106115 }
107116 }
108117 }
@@ -225,7 +234,14 @@ internal static partial class TestPartial
225234}}
226235" ;
227236
228- await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
237+ var languageVersion = ( LightupHelpers . SupportsCSharp8 , LightupHelpers . SupportsCSharp72 ) switch
238+ {
239+ // Make sure to use C# 7.2 if supported, unless we are going to default to something greater
240+ ( false , true ) => LanguageVersionEx . CSharp7_2 ,
241+ _ => ( LanguageVersion ? ) null ,
242+ } ;
243+
244+ await VerifyCSharpDiagnosticAsync ( languageVersion , testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
229245 }
230246
231247 /// <summary>
@@ -294,7 +310,14 @@ public class Foo
294310}}
295311" ;
296312
297- await VerifyCSharpFixAsync ( testCode , Diagnostic ( ) . WithLocation ( 8 , 14 + typeKeyword . Length ) , fixedTestCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
313+ var languageVersion = ( LightupHelpers . SupportsCSharp8 , LightupHelpers . SupportsCSharp72 ) switch
314+ {
315+ // Make sure to use C# 7.2 if supported, unless we are going to default to something greater
316+ ( false , true ) => LanguageVersionEx . CSharp7_2 ,
317+ _ => ( LanguageVersion ? ) null ,
318+ } ;
319+
320+ await VerifyCSharpFixAsync ( languageVersion , testCode , Diagnostic ( ) . WithLocation ( 8 , 14 + typeKeyword . Length ) , fixedTestCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
298321 }
299322 }
300323}
0 commit comments