From af7c8c9170ad1e7fcec987ac0dca8567be78091d Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Tue, 29 Jan 2019 09:45:40 -0800 Subject: [PATCH] Address verification issue in 30747 The `MissingTypeKindBasisTypes` test is copied from `UseSiteErrorTests` and given verification succeeds there it's reasonable to expect that it would succeed here. However there are a few factors here that aren't obvious at a glance. The first is that not all of the compilations in `UseSiteErrorTests` are verifable. The `compilation1` is not verifiable in either suite, it's hard to miss because it's not tested. The reason why is that the corlib reference name is mincorlib, not mscorlib. PEVerify is hard coded to think the name of corlib will always be mscorlib. Hence any attempt to verify against a different name corlib will always fail. Well ... almost always. It fails only when it's used in the IL. For `compilation2` there is no direct reference to corlib, hence mincorlib doesn't appear in the IL and it passes verification. With NRT though we silently emit an attribute in the binary for nullable tracking and this does reference corlib (the attribute derives from `System.Attribute`) and hence verification fails. Adjusted the suite to make this expected. closes #30747 --- .../Semantics/NullableReferenceTypesTests.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index 156c4b0d58b..fe7e26c0386 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,7 @@ interface I2 var compilation2 = CreateEmptyCompilation(source2, options: WithNonNullTypesTrue(TestOptions.ReleaseDll), references: new[] { compilation1.EmitToImageReference(), MinCorlibRef }); compilation2.VerifyEmitDiagnostics(); - CompileAndVerify(compilation2); + CompileAndVerify(compilation2, verify: Verification.Fails); Assert.Equal(TypeKind.Struct, compilation2.GetTypeByMetadataName("A").TypeKind); Assert.Equal(TypeKind.Enum, compilation2.GetTypeByMetadataName("B").TypeKind); @@ -59327,7 +59327,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 +59369,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 }); -- GitLab