提交 844a7bc3 编写于 作者: J Julien Couvreur 提交者: GitHub

Refreshing reference source for ValueTuple and add test for serialization (#16938)

上级 8f999eef
......@@ -22022,5 +22022,41 @@ static void Main()
);
}
[Fact]
public void Serialization()
{
var source = @"
using System;
class C
{
public static void Main()
{
VerifySerialization(new ValueTuple());
VerifySerialization(ValueTuple.Create(1));
VerifySerialization((1, 2, 3, 4, 5, 6, 7, 8));
Console.WriteLine(""DONE"");
}
public static void VerifySerialization<T>(T tuple)
{
var serializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
var writer = new System.IO.StringWriter();
serializer.Serialize(writer, tuple);
string xml = writer.ToString();
object output = serializer.Deserialize(new System.IO.StringReader(xml));
if (!tuple.Equals(output))
{
throw new Exception(""Deserialization output didn't match"");
}
}
}";
var comp = CreateCompilationWithMscorlib(new[] { source, tuplelib_cs },
references: new[] { SystemXmlRef }, options: TestOptions.DebugExe);
comp.VerifyDiagnostics();
CompileAndVerify(comp, expectedOutput: "DONE");
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册