diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs index f9c2b43d59737..80e361e68fe6e 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs @@ -231,7 +231,7 @@ static void Main() VerifyFieldSymbol(comp.GetMember("S.F"), "ref T S.F", RefKind.Ref, new string[0]); - comp = CreateEmptyCompilation(sourceB, references: new[] { refA, mscorlibRefWithRefFields }, parseOptions: TestOptions.Regular11); + comp = CreateEmptyCompilation(sourceB, references: new[] { refA, mscorlibRefWithRefFields }, parseOptions: TestOptions.Regular11, options: TestOptions.ReleaseExe); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"2 2 @@ -311,7 +311,7 @@ static void Main() VerifyFieldSymbol(comp.GetMember("S.F"), "ref readonly T S.F", RefKind.RefReadOnly, new string[0]); - comp = CreateEmptyCompilation(sourceB, references: new[] { refA, mscorlibRefWithRefFields }, parseOptions: TestOptions.Regular11); + comp = CreateEmptyCompilation(sourceB, references: new[] { refA, mscorlibRefWithRefFields }, parseOptions: TestOptions.Regular11, options: TestOptions.ReleaseExe); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"2 2 @@ -588,7 +588,7 @@ public R() } } """; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("explicit ctor")); verifier.VerifyIL("R..ctor()", @" @@ -627,7 +627,7 @@ public R() } } """; - var comp = CreateCompilation(source, targetFramework: TargetFramework.Net60); + var comp = CreateCompilation(source, targetFramework: TargetFramework.Net60, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("explicit ctor")); verifier.VerifyIL("R..ctor()", @" @@ -663,7 +663,7 @@ public R() } } """; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("explicit ctor")); @@ -699,7 +699,7 @@ public R() } } """; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics( // (7,29): warning CS0649: Field 'R.field' is never assigned to, and will always have its default value 0 // public readonly ref int field; @@ -742,7 +742,7 @@ public R() } } """; - var comp = CreateCompilation(source, parseOptions: TestOptions.Regular11, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, parseOptions: TestOptions.Regular11, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("explicit ctor")); verifier.VerifyIL("R..ctor()", @" @@ -4042,7 +4042,7 @@ static void Main() Console.WriteLine(s.F); } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"2 2 @@ -4447,7 +4447,7 @@ static void Main() Console.WriteLine(s.F); } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"2 2 @@ -4857,7 +4857,7 @@ static void Main() Console.WriteLine(s.F); } }"; - comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"1 4 @@ -5013,7 +5013,7 @@ static void Main() Console.WriteLine(s.F); } }"; - comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"1 1 @@ -6054,7 +6054,7 @@ static void NewField(ref R r) r.S = new S(); } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"42 42 @@ -6100,7 +6100,7 @@ static void Write(S s, int value) s.F = value; } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"42 42 @@ -6245,7 +6245,7 @@ static void ReadAndDiscard2(in S s) // https://github.com/dotnet/roslyn/issues/62122: The dereference of a ref field // should be emitted to IL, even if the value is ignored, because the behavior // may be observable as a NullReferenceException. - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("")); verifier.VerifyIL("Program.ReadAndDiscard1", @"{ @@ -6293,7 +6293,7 @@ static void Main() static ref T RefReturn(S s) => ref s.F; static ref readonly T RefReadonlyReturn(S s) => ref s.F; }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("2")); var expectedIL = @"{ @@ -6330,7 +6330,7 @@ static void Main() static ref T RefReturn(ref S s) => ref s.F; static ref readonly T RefReadonlyReturn(ref S s) => ref s.F; }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("2")); var expectedIL = @"{ @@ -6367,7 +6367,7 @@ static void Main() static ref T RefReturn(in S s) => ref s.F; static ref readonly T RefReadonlyReturn(in S s) => ref s.F; }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("2")); var expectedIL = @"{ @@ -6412,7 +6412,7 @@ static ref readonly T RefReadonlyReturn(out S s, ref T t) return ref s.F; } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("2")); var expectedIL = @"{ @@ -6462,7 +6462,7 @@ static void Subtract(S s, int offset) s.F -= offset; } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"43 43 @@ -6531,7 +6531,7 @@ static void Main() Console.WriteLine(x); }} }}"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"43 43 @@ -6602,7 +6602,7 @@ static ref T ConditionalOperatorRef(bool b, ref S sx, ref S sy) return ref b ? ref sx.F : ref sy.F; } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"1 2 @@ -6665,7 +6665,7 @@ static string ConditionalAccess(S s) return s.F?.ToString(); } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"1 2 @@ -6804,7 +6804,7 @@ static void M(in T x, in T y) Console.WriteLine(y); } }"; - var comp = CreateCompilation(new[] { source, UnscopedRefAttributeDefinition }, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(new[] { source, UnscopedRefAttributeDefinition }, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"1 2 @@ -7126,7 +7126,7 @@ static void Main() Console.WriteLine(s.t); } }"; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput( @"2 2 @@ -12228,7 +12228,7 @@ public override string ToString() } } "; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("42")); verifier.VerifyIL("C.Main", @@ -12967,7 +12967,7 @@ public void RefInitializer_Nested() var source = @" class C { - void M() + static void Main() { int x = 42; var r = new Container { item = { field = ref x } }; @@ -12983,10 +12983,10 @@ ref struct Item public ref int field; } "; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("42")); - verifier.VerifyIL("C.M", @" + verifier.VerifyIL("C.Main", @" { // Code size 42 (0x2a) .maxstack 2 @@ -13036,7 +13036,7 @@ ref struct R public ref S field; } "; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics( // (8,33): warning CS8619: Nullability of reference types in value of type 'S' doesn't match target type 'S'. // _ = new R { field = ref x2 }; // 1 @@ -13069,7 +13069,7 @@ ref struct R public ref S field; } "; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics( // (2,5): warning CS0219: The variable 'x' is assigned but its value is never used // int x = 42; @@ -13618,7 +13618,7 @@ public override string ToString() } } "; - var comp = CreateCompilation(source, runtimeFeature: RuntimeFlag.ByRefFields); + var comp = CreateCompilation(source, options: TestOptions.ReleaseExe, runtimeFeature: RuntimeFlag.ByRefFields); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput("42")); verifier.VerifyIL("C.Main",