I have a class which is automatically generated via wsdl.exe, I need to add the [System.Xml.Serialization.XmlIgnoreAttribute()] attribute to one of the properties, but I can't modify the class directly as it is regenerated every now and then.
Is there any way to do this? I already tried searching for solutions with inheritance, partial classes and reflection but without luck. I'm stuck with .NET Framework 2.0 because of customer's constraints.
(more details on why I need to do this here: Prevent timezone conversion on deserialization of DateTime value, I'm adding the string property in a partial class)
EDIT: A requested code snippet is a simple as this:
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://common.ws.model.plx.ids.it/")]
public partial class publication {
private System.DateTime dateFromField;
//[System.Xml.Serialization.XmlIgnoreAttribute()] I would like to add this
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public System.DateTime dateFrom {
get {
return this.dateFromField;
}
set {
this.dateFromField = value;
}
}
///// This method has been moved in the other partial class
//[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, ElementName = "dateFrom")]
//public string dateFromString
//{
// get
// {
// return XmlConvert.ToString(dateFrom, XmlDateTimeSerializationMode.RoundtripKind);
// }
// set
// {
// dateFrom = DateTimeOffset.Parse(value).DateTime;
// }
//}
}