未验证 提交 53971731 编写于 作者: J Jared Parsons 提交者: GitHub

Merge pull request #32913 from jaredpar/fix-test

Complete a number of nullable test issues
......@@ -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 });
......@@ -2032,6 +2032,33 @@ protected static CSharpCompilation CreateCompilationWithIndexAndRangeAndSpan(CSh
}
#endregion
#region Theory Helpers
public static IEnumerable<object[]> NonNullTypesTrueAndFalseDebugDll
{
get
{
return new List<object[]>()
{
new object[] { WithNonNullTypesTrue(TestOptions.DebugDll) },
new object[] { WithNonNullTypesFalse(TestOptions.DebugDll) }
};
}
}
public static IEnumerable<object[]> NonNullTypesTrueAndFalseReleaseDll
{
get
{
return new List<object[]>()
{
new object[] { WithNonNullTypesTrue(TestOptions.ReleaseDll) },
new object[] { WithNonNullTypesFalse(TestOptions.ReleaseDll) }
};
}
}
#endregion
protected static readonly string s_IAsyncEnumerable = @"
namespace System.Collections.Generic
{
......
......@@ -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<T>(object x) where T : A, new()
}
}
}";
var compilation0 = CreateCompilation(source, options: TestOptions.DebugDll);
var compilation0 = CreateCompilation(source, options: options);
WithRuntimeInstance(compilation0, runtime =>
{
......
......@@ -1628,8 +1628,9 @@ .maxstack 1
/// Should not include "this" inside display class
/// instance method if "this" is not captured.
/// </summary>
[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.<M>b__0");
......
......@@ -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<NamedTypeSymbol>("System.Object");
Assert.NotNull(objectType.BaseType());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册