This project is read-only.

Validation is disabled for attributes

Jul 12, 2013 at 12:37 PM
I saw that in ClrPropertyInfo.SetValuMethodCall() the validation is deliberately ignored for Attributes, c.f.
private CodeMethodInvokeExpression SetValueMethodCall() 
{
// [...]
switch(propertyOrigin) 
{
  case SchemaOrigin.Element:
    setMethodName = string.Concat(setMethodName, "Element");
    break;
    
  case SchemaOrigin.Attribute:
    validation = false; // <----------------------------------------
    setMethodName = string.Concat(setMethodName, "Attribute");
    break;
    
  case SchemaOrigin.Text:
    setMethodName = string.Concat(setMethodName, "Value");
    xNameParm = false;
    break;
    
  case SchemaOrigin.None:
  default:
    throw new InvalidOperationException();                            
}
// [...]
}
If I take this line out, the generated code also validates property setters belonging to attributes. The same way it does for elements. It seems to work perfectly fine. Is there any reason why it is disabled?