@@ -2346,33 +2346,61 @@ public void UsingRefExtensionMethodsBeforeVersion7_2ProducesDiagnostics_InSyntax
23462346 var code = @"
23472347public static class Ext
23482348{
2349- public static void Print(in this int p)
2350- {
2351- System.Console.WriteLine(p);
2352- }
2349+ public static void Print0(in this int p)
2350+ => System.Console.Write(p);
2351+ public static void Print1(this in int p)
2352+ => System.Console.Write(p);
2353+ public static void Print2(ref this int p)
2354+ => System.Console.Write(p);
2355+ public static void Print3(this ref int p)
2356+ => System.Console.Write(p);
23532357}
23542358public static class Program
23552359{
23562360 public static void Main()
23572361 {
23582362 int p = 5;
2359- p.Print();
2363+ p.Print0();
2364+ p.Print1();
2365+ p.Print2();
2366+ p.Print3();
23602367 }
23612368}" ;
23622369
23632370 CreateCompilationWithMscorlib40AndSystemCore ( code , parseOptions : CSharpParseOptions . Default . WithLanguageVersion ( LanguageVersion . CSharp7_1 ) ) . VerifyDiagnostics (
2364- // (4,30): error CS8302: Feature 'readonly references' is not available in C# 7.1. Please use language version 7.2 or greater.
2365- // public static void Print(in this int p)
2366- Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "in" ) . WithArguments ( "readonly references" , "7.2" ) . WithLocation ( 4 , 30 ) ,
2367- // (4,30): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2368- // public static void Print(in this int p)
2369- Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "in" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 4 , 30 ) ,
2370- // (14,9): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2371- // p.Print();
2372- Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "p" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 14 , 9 )
2373- ) ;
2374-
2375- CompileAndVerify ( code , expectedOutput : "5" ) ;
2371+ // (4,31): error CS8302: Feature 'readonly references' is not available in C# 7.1. Please use language version 7.2 or greater.
2372+ // public static void Print0(in this int p)
2373+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "in" ) . WithArguments ( "readonly references" , "7.2" ) . WithLocation ( 4 , 31 ) ,
2374+ // (4,31): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2375+ // public static void Print0(in this int p)
2376+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "in" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 4 , 31 ) ,
2377+ // (6,31): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2378+ // public static void Print1(this in int p)
2379+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "this" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 6 , 31 ) ,
2380+ // (6,36): error CS8302: Feature 'readonly references' is not available in C# 7.1. Please use language version 7.2 or greater.
2381+ // public static void Print1(this in int p)
2382+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "in" ) . WithArguments ( "readonly references" , "7.2" ) . WithLocation ( 6 , 36 ) ,
2383+ // (8,31): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2384+ // public static void Print2(ref this int p)
2385+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "ref" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 8 , 31 ) ,
2386+ // (10,31): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2387+ // public static void Print3(this ref int p)
2388+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "this" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 10 , 31 ) ,
2389+ // (18,9): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2390+ // p.Print0();
2391+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "p" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 18 , 9 ) ,
2392+ // (19,9): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2393+ // p.Print1();
2394+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "p" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 19 , 9 ) ,
2395+ // (20,9): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2396+ // p.Print2();
2397+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "p" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 20 , 9 ) ,
2398+ // (21,9): error CS8302: Feature 'ref extension methods' is not available in C# 7.1. Please use language version 7.2 or greater.
2399+ // p.Print3();
2400+ Diagnostic ( ErrorCode . ERR_FeatureNotAvailableInVersion7_1 , "p" ) . WithArguments ( "ref extension methods" , "7.2" ) . WithLocation ( 21 , 9 )
2401+ ) ;
2402+
2403+ CompileAndVerify ( code , expectedOutput : "5555" ) ;
23762404 }
23772405
23782406 [ Fact ]
0 commit comments