Closed jods4 closed 3 years ago
I'm working on this. Do you happen to know why validation of attribute values is disabled? https://github.com/mamift/LinqToXsdCore/blob/master/XObjectsCode/Src/ClrPropertyInfo.cs#L868
(not gonna change this in the PR but it struck me as odd?)
It also struck me as odd that the ToString
call on enums is only on the xNameParm
branches.
https://github.com/mamift/LinqToXsdCore/blob/master/XObjectsCode/Src/ClrPropertyInfo.cs#L928
xNameParm
actually indicates whether the origin of the value is element/attribute vs text content.
When xNameParm
is false
, the the origin is text content and SetValue
is called.
https://github.com/mamift/LinqToXsdCore/blob/master/XObjectsCode/Src/ClrPropertyInfo.cs#L872-L875
Should that text content be typed as an enum, I don't see why it shouldn't be formatted ToString
the same way it would be in an attribute or child element.
I'm changing this as it seems like a logical thing to do + it makes my new code easier.
Done in #28, as well as another NRE crash unrelated to validation when setting nullable enum attributes.
I'm working on this. Do you happen to know why validation of attribute values is disabled? https://github.com/mamift/LinqToXsdCore/blob/master/XObjectsCode/Src/ClrPropertyInfo.cs#L868
(not gonna change this in the PR but it struck me as odd?)
I know I'm replying after the fact, but to address your question, no I don't know why. But agree with your change, and that it's odd.
Just to be sure there is no misunderstanding:
But agree with your change
I left attribute validation disabled as I was afraid of the reason why it was disabled in the first place: https://github.com/mamift/LinqToXsdCore/blob/master/XObjectsCode/Src/ClrPropertyInfo.cs#L871
The generated setter for a nullable DateTime looks like this:
Trying to remove such an element by setting it to null fails with an exception. The setter calls
SetElementWithValidation
with valuenull
and the validation first performed by this method fails, although the code after validation would correctly remove the element upon receiving anull
value.Notice that the situation is slightly worse for an enum, because the generated code passes
value.ToString()
toSetElementWithValidation
and that.ToString()
would fail even earlier.