C# XmlInclude在Unii测试项目中
我试图在单元测试中使用C# XmlInclude在Unii测试项目中,c#,visual-studio,unit-testing,C#,Visual Studio,Unit Testing,我试图在单元测试中使用xmlclude(在VisualStudio测试项目中),我收到了奇怪的错误消息CS1729;'XmlIgnoreAttribute'不包含接受1个参数的构造函数。在非单元测试项目中,代码编译良好。有人知道为什么吗 [TestMethod] public void TestAndExplore() { Test x = new Test(); Serialization.SerializeToXmlString(x);
xmlclude
(在VisualStudio测试项目中),我收到了奇怪的错误消息CS1729;'XmlIgnoreAttribute'不包含接受1个参数的构造函数
。在非单元测试项目中,代码编译良好。有人知道为什么吗
[TestMethod]
public void TestAndExplore()
{
Test x = new Test();
Serialization.SerializeToXmlString(x);
}
public class Test : ModelBase { public Base Base { get; set; } = new Derived(); }
[XmlInclude(typeof(Derived))]
public class Base { }
public class Derived : Base { }
这个问题与XmlInclude无关。您的代码中有XmlIgnoreAttribute,这是您在post.Hm中完成的。我有这样一句话:
[xmlclude(typeof(派生))]
那行有什么问题?没有。是的,但在单元测试项目中使用时,它会给出CS1729错误消息。您正在执行以下操作: