c# - will RegularExpressionAttribute and other validators on Automatic properties work? -
i'm using xsd2code generating classes schema. how ever i'm suspicious auto properties can validate values or not?
because if enable automaticproperties
in xsd2code here member regex restriction.
[system.xml.serialization.xmlattributeattribute(datatype="token", attributename="color")] [system.componentmodel.dataannotations.regularexpressionattribute("#[\\da-f]{6}([\\da-f][\\da-f])?")] public string color { get; set; }
and when automaticproperties
disabled
[system.xml.serialization.xmlattributeattribute(datatype="token", attributename="color")] [system.componentmodel.dataannotations.regularexpressionattribute("#[\\da-f]{6}([\\da-f][\\da-f])?")] public string color { { return this._color; } set { system.componentmodel.dataannotations.validationcontext validatorpropcontext = new system.componentmodel.dataannotations.validationcontext(this, null, null); validatorpropcontext.membername = "color"; validator.validateproperty(value, validatorpropcontext); this._color = value; } }
it seems these not equivalent. think bug in xsd2code or maybe i'm misunderstanding something. whats purpose of second generated code?
i thought regularexpressionattribute
validate automatic properties too.
Comments
Post a Comment