未验证 提交 b0bd4af8 编写于 作者: J Julien Couvreur 提交者: GitHub

Add test for obsolete Deconstruct method (#23931)

上级 92eadcd8
......@@ -126,6 +126,41 @@ .maxstack 3
}");
}
[Fact]
public void ObsoleteDeconstructMethod()
{
string source = @"
class C
{
static void Main()
{
long x;
string y;
(x, y) = new C();
foreach (var (z1, z2) in new[] { new C() }) { }
}
[System.Obsolete]
public void Deconstruct(out int a, out string b)
{
a = 1;
b = ""hello"";
}
}
";
var comp = CreateStandardCompilation(source, references: s_valueTupleRefs);
comp.VerifyDiagnostics(
// (9,18): warning CS0612: 'C.Deconstruct(out int, out string)' is obsolete
// (x, y) = new C();
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "new C()").WithArguments("C.Deconstruct(out int, out string)").WithLocation(9, 18),
// (10,34): warning CS0612: 'C.Deconstruct(out int, out string)' is obsolete
// foreach (var (z1, z2) in new[] { new C() }) { }
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "new[] { new C() }").WithArguments("C.Deconstruct(out int, out string)").WithLocation(10, 34)
);
}
[Fact]
[WorkItem(13632, "https://github.com/dotnet/roslyn/issues/13632")]
public void SimpleAssignWithoutConversion()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册