提交 33e17d11 编写于 作者: C Charles Stoner

Fix tests

上级 61f2563a
......@@ -1249,6 +1249,7 @@ static void Main()
}
[Fact]
[WorkItem(45519, "https://github.com/dotnet/roslyn/issues/45519")]
public void EmitAttribute_PartialMethods()
{
var source =
......@@ -1260,13 +1261,13 @@ public void EmitAttribute_PartialMethods()
static partial void F2(nuint x);
}";
var comp = CreateCompilation(source, options: TestOptions.ReleaseDll.WithMetadataImportOptions(MetadataImportOptions.All), parseOptions: TestOptions.Regular9);
// Ideally should not emit any attributes. Compare with dynamic/object.
var expected =
@"Program
void F2(System.UIntPtr x)
[NativeInteger] System.UIntPtr x
";
AssertNativeIntegerAttributes(comp, expected);
comp.VerifyEmitDiagnostics(
// (4,25): error CS8824: Partial method declarations 'void Program.F2(nuint x)' and 'void Program.F2(UIntPtr x)' must have identical parameter types and identical return types.
// static partial void F2(System.UIntPtr x) { }
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "F2").WithArguments("void Program.F2(nuint x)", "void Program.F2(UIntPtr x)").WithLocation(4, 25),
// (5,25): error CS8824: Partial method declarations 'void Program.F1(IntPtr x)' and 'void Program.F1(nint x)' must have identical parameter types and identical return types.
// static partial void F1(nint x) { }
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "F1").WithArguments("void Program.F1(IntPtr x)", "void Program.F1(nint x)").WithLocation(5, 25));
}
// Shouldn't depend on [NullablePublicOnly].
......
......@@ -2687,7 +2687,13 @@ partial class C
public partial IEnumerable<string> M2() => null!;
}";
var comp = CreateCompilation(source, parseOptions: TestOptions.RegularWithExtendedPartialMethods);
comp.VerifyDiagnostics();
comp.VerifyDiagnostics(
// (8,27): error CS8824: Partial method declarations 'string? C.M1()' and 'string C.M1()' must have identical parameter types and identical return types.
// public partial string M1() => "hello";
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "M1").WithArguments("string? C.M1()", "string C.M1()").WithLocation(8, 27),
// (11,40): error CS8824: Partial method declarations 'IEnumerable<string?> C.M2()' and 'IEnumerable<string> C.M2()' must have identical parameter types and identical return types.
// public partial IEnumerable<string> M2() => null!;
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "M2").WithArguments("IEnumerable<string?> C.M2()", "IEnumerable<string> C.M2()").WithLocation(11, 40));
}
[Fact, WorkItem(44930, "https://github.com/dotnet/roslyn/issues/44930")]
......@@ -2967,7 +2973,13 @@ partial class C
public partial object M2() => null;
}";
var comp = CreateCompilation(source, parseOptions: TestOptions.RegularWithExtendedPartialMethods);
comp.VerifyDiagnostics();
comp.VerifyDiagnostics(
// (5,28): error CS8824: Partial method declarations 'object C.M1()' and 'dynamic C.M1()' must have identical parameter types and identical return types.
// public partial dynamic M1() => null;
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "M1").WithArguments("object C.M1()", "dynamic C.M1()").WithLocation(5, 28),
// (8,27): error CS8824: Partial method declarations 'dynamic C.M2()' and 'object C.M2()' must have identical parameter types and identical return types.
// public partial object M2() => null;
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "M2").WithArguments("dynamic C.M2()", "object C.M2()").WithLocation(8, 27));
}
[Fact, WorkItem(44930, "https://github.com/dotnet/roslyn/issues/44930")]
......@@ -2985,7 +2997,13 @@ partial class C
public partial IntPtr M2() => default;
}";
var comp = CreateCompilation(source, parseOptions: TestOptions.RegularWithExtendedPartialMethods);
comp.VerifyDiagnostics();
comp.VerifyDiagnostics(
// (7,25): error CS8824: Partial method declarations 'IntPtr C.M1()' and 'nint C.M1()' must have identical parameter types and identical return types.
// public partial nint M1() => 0;
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "M1").WithArguments("IntPtr C.M1()", "nint C.M1()").WithLocation(7, 25),
// (10,27): error CS8824: Partial method declarations 'nint C.M2()' and 'IntPtr C.M2()' must have identical parameter types and identical return types.
// public partial IntPtr M2() => default;
Diagnostic(ErrorCode.ERR_PartialMethodSignatureDifference, "M2").WithArguments("nint C.M2()", "IntPtr C.M2()").WithLocation(10, 27));
}
[Fact, WorkItem(44930, "https://github.com/dotnet/roslyn/issues/44930")]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册