diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index 156c4b0d58bb247253214fb9b8661bcc0bb71590..aed887a91dcd6294b61cf31b32e5ba540b3bef3f 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -59283,7 +59283,7 @@ static void Main() }); } - [Fact(Skip = "https://github.com/dotnet/roslyn/issues/30747 Type load failed.")] + [Fact] [WorkItem(30747, "https://github.com/dotnet/roslyn/issues/30747")] public void MissingTypeKindBasisTypes() { @@ -59316,7 +59316,9 @@ interface I2 var compilation2 = CreateEmptyCompilation(source2, options: WithNonNullTypesTrue(TestOptions.ReleaseDll), references: new[] { compilation1.EmitToImageReference(), MinCorlibRef }); compilation2.VerifyEmitDiagnostics(); - CompileAndVerify(compilation2); + + // Verification against a corlib not named exactly mscorlib is expected to fail. + CompileAndVerify(compilation2, verify: Verification.Fails); Assert.Equal(TypeKind.Struct, compilation2.GetTypeByMetadataName("A").TypeKind); Assert.Equal(TypeKind.Enum, compilation2.GetTypeByMetadataName("B").TypeKind); @@ -59327,7 +59329,7 @@ interface I2 var compilation3 = CreateEmptyCompilation(source2, options: WithNonNullTypesTrue(TestOptions.ReleaseDll), references: new[] { compilation1.ToMetadataReference(), MinCorlibRef }); compilation3.VerifyEmitDiagnostics(); - CompileAndVerify(compilation3); + CompileAndVerify(compilation3, verify: Verification.Fails); Assert.Equal(TypeKind.Struct, compilation3.GetTypeByMetadataName("A").TypeKind); Assert.Equal(TypeKind.Enum, compilation3.GetTypeByMetadataName("B").TypeKind); @@ -59369,15 +59371,13 @@ interface I2 compilation5.VerifyEmitDiagnostics( // warning CS8021: No value for RuntimeMetadataVersion found. No assembly containing System.Object was found nor was a value for RuntimeMetadataVersion specified through options. - Diagnostic(ErrorCode.WRN_NoRuntimeMetadataVersion).WithLocation(1, 1) - ); - CompileAndVerify(compilation5); - - Assert.Equal(TypeKind.Struct, compilation5.GetTypeByMetadataName("A").TypeKind); - Assert.Equal(TypeKind.Enum, compilation5.GetTypeByMetadataName("B").TypeKind); - Assert.Equal(TypeKind.Class, compilation5.GetTypeByMetadataName("C").TypeKind); - Assert.Equal(TypeKind.Delegate, compilation5.GetTypeByMetadataName("D").TypeKind); - Assert.Equal(TypeKind.Interface, compilation5.GetTypeByMetadataName("I1").TypeKind); + Diagnostic(ErrorCode.WRN_NoRuntimeMetadataVersion).WithLocation(1, 1), + // error CS0518: Predefined type 'System.Attribute' is not defined or imported + Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound).WithArguments("System.Attribute").WithLocation(1, 1), + // error CS0518: Predefined type 'System.Attribute' is not defined or imported + Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound).WithArguments("System.Attribute").WithLocation(1, 1), + // error CS0518: Predefined type 'System.Byte' is not defined or imported + Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound).WithArguments("System.Byte").WithLocation(1, 1)); var compilation6 = CreateEmptyCompilation(source2, options: WithNonNullTypesTrue(TestOptions.ReleaseDll), references: new[] { compilation1.EmitToImageReference(), MscorlibRef }); diff --git a/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs b/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs index 5eb499b4e662b59dd108366ea591070b969cdf77..dfff3a63af5983c34f99f68e31f3139ff80e0fa8 100644 --- a/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs +++ b/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs @@ -2032,6 +2032,33 @@ protected static CSharpCompilation CreateCompilationWithIndexAndRangeAndSpan(CSh } #endregion + #region Theory Helpers + + public static IEnumerable NonNullTypesTrueAndFalseDebugDll + { + get + { + return new List() + { + new object[] { WithNonNullTypesTrue(TestOptions.DebugDll) }, + new object[] { WithNonNullTypesFalse(TestOptions.DebugDll) } + }; + } + } + + public static IEnumerable NonNullTypesTrueAndFalseReleaseDll + { + get + { + return new List() + { + new object[] { WithNonNullTypesTrue(TestOptions.ReleaseDll) }, + new object[] { WithNonNullTypesFalse(TestOptions.ReleaseDll) } + }; + } + } + #endregion + protected static readonly string s_IAsyncEnumerable = @" namespace System.Collections.Generic { diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ExpressionCompilerTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ExpressionCompilerTests.cs index aa92b7c4f9b8048c71c1c5c8e9aceae967566647..d629c8203eac68e45d922023cde5335d1e993ee9 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ExpressionCompilerTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ExpressionCompilerTests.cs @@ -3029,8 +3029,9 @@ .maxstack 1 }); } - [Fact] - public void EvaluateCapturedLocalsOutsideLambda() + [Theory] + [MemberData(nameof(NonNullTypesTrueAndFalseDebugDll))] + public void EvaluateCapturedLocalsOutsideLambda(CSharpCompilationOptions options) { var source = @"class A @@ -3067,7 +3068,7 @@ void M(object x) where T : A, new() } } }"; - var compilation0 = CreateCompilation(source, options: TestOptions.DebugDll); + var compilation0 = CreateCompilation(source, options: options); WithRuntimeInstance(compilation0, runtime => { diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs index 7aebf854a16a3327147210f1ab6ecfb0adba70b6..92d992c0dbcaf00032e0c2da77a94515aa0efb8d 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs @@ -1628,8 +1628,9 @@ .maxstack 1 /// Should not include "this" inside display class /// instance method if "this" is not captured. /// - [Fact] - public void NoThisInsideDisplayClassInstanceMethod() + [Theory] + [MemberData(nameof(NonNullTypesTrueAndFalseDebugDll))] + public void NoThisInsideDisplayClassInstanceMethod(CSharpCompilationOptions options) { var source = @"using System; @@ -1647,7 +1648,7 @@ class C f(2)(x); } }"; - var compilation0 = CreateCompilation(source, options: TestOptions.DebugDll); + var compilation0 = CreateCompilation(source, options: options); WithRuntimeInstance(compilation0, runtime => { var context = CreateMethodContext(runtime, "C.<>c__DisplayClass0_0.b__0"); diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs index 0d796d986fcd72fbe25a00cc919e15e0f3915664..c1d181ecb603a149417d1f725080e322ad445eda 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs @@ -1367,8 +1367,9 @@ .maxstack 1 // References to missing assembly from PDB custom debug info. [WorkItem(13275, "https://github.com/dotnet/roslyn/issues/13275")] - [Fact] - public void CorLibWithAssemblyReferences_Pdb() + [Theory] + [MemberData(nameof(NonNullTypesTrueAndFalseReleaseDll))] + public void CorLibWithAssemblyReferences_Pdb(CSharpCompilationOptions options) { string sourceLib = @"namespace Namespace @@ -1397,7 +1398,7 @@ public class Void : Object { } }"; // Create a custom corlib with a reference to compilation // above and a reference to the actual mscorlib. - var compCorLib = CreateEmptyCompilation(sourceCorLib, assemblyName: CorLibAssemblyName, references: new[] { MscorlibRef, refLib }); + var compCorLib = CreateEmptyCompilation(sourceCorLib, assemblyName: CorLibAssemblyName, references: new[] { MscorlibRef, refLib }, options: options); compCorLib.VerifyDiagnostics(); var objectType = compCorLib.SourceAssembly.GlobalNamespace.GetMember("System.Object"); Assert.NotNull(objectType.BaseType());