作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
<分区>
我正在尝试分析一些 trx 文件 (webTestResults) 以输出合成 excel 文件。
首先,我使用 trx xsd 架构(visual studio 目录中的 vstst.xsd)生成一堆 C# 类。
然后,我尝试根据 TestRunType 的类型(从模式生成)实例化一个 XmlSerializer。
XmlSerializer xmlSer = new XmlSerializer(typeof(TestRunType));
XMLSerializer 实例化引发异常:
System.InvalidOperationException: There was an error reflecting type 'TestRunType'. ---> System.InvalidOperationException: There was an error reflecting property 'Items'. ---> System.InvalidOperationException: There was an error reflecting type 'TestRunTypeTestDefinitions'. ---> System.InvalidOperationException: There was an error reflecting property 'Items'. ---> System.InvalidOperationException: There was an error reflecting type 'OrderedTestType'. ---> System.InvalidOperationException: There was an error reflecting type 'CodedWebTestElementType'. ---> System.InvalidOperationException: There was an error reflecting property 'Items'. ---> System.InvalidOperationException: Member 'CodedWebTestElementType.Items' hides inherited member 'BaseTestType.Items', but has different custom attributes.
at System.Xml.Serialization.StructMapping.FindDeclaringMapping(MemberMapping member, StructMapping& declaringMapping, String parent)
at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
自定义属性是什么?只是 BaseTestType 的开始:
public abstract partial class BaseTestType {
private object[] itemsField;
private bool enabledField;
private string idField;
private string nameField;
private bool isGroupableField;
private int priorityField;
private string namedCategoryField;
private string storageField;
public BaseTestType() {
this.enabledField = true;
this.isGroupableField = true;
this.priorityField = 2147483647;
this.namedCategoryField = "";
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Agent", typeof(BaseTestTypeAgent))]
[System.Xml.Serialization.XmlElementAttribute("Css", typeof(BaseTestTypeCss))]
[System.Xml.Serialization.XmlElementAttribute("DeploymentItems", typeof(BaseTestTypeDeploymentItems))]
[System.Xml.Serialization.XmlElementAttribute("Description", typeof(object))]
[System.Xml.Serialization.XmlElementAttribute("Execution", typeof(BaseTestTypeExecution))]
[System.Xml.Serialization.XmlElementAttribute("Owners", typeof(BaseTestTypeOwners))]
[System.Xml.Serialization.XmlElementAttribute("Properties", typeof(BaseTestTypeProperties))]
[System.Xml.Serialization.XmlElementAttribute("TcmInformation", typeof(TcmInformationType))]
[System.Xml.Serialization.XmlElementAttribute("TestCategory", typeof(BaseTestTypeTestCategory))]
[System.Xml.Serialization.XmlElementAttribute("WorkItemIDs", typeof(WorkItemIDsType))]
public object[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
和 CodedWebTestElementType :
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://microsoft.com/schemas/VisualStudio/TeamTest/2010")]
public partial class CodedWebTestElementType : BaseTestType {
private object[] itemsField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("IncludedWebTests", typeof(CodedWebTestElementTypeIncludedWebTests))]
[System.Xml.Serialization.XmlElementAttribute("WebTestClass", typeof(CodedWebTestElementTypeWebTestClass))]
public object[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
}
有人可以向我解释一下问题是什么吗?
谢谢...
这个问题在这里已经有了答案: .net XmlSerializer on overridden properties (2 个答案) 关闭 9 年前。 我正在尝试分析一些 trx 文件 (webTe
我是一名优秀的程序员,十分优秀!