❔ XML attributes with different name and type, but same type.Name
Hi! Here is a cut down of the problem i'm having:
And this is the error I'm getting:
From what I understand, the problem the serializer is having is that it is only able to associate a type by its class name, not the whole name.
I'm not quite sure how to approach this, because the nested types may not be under my control.
I would have imagined that because its an attribute and not an element, that the conflict shouldn't matter.
10 Replies
this is probably more an issue of the fact that you're trying to model entire objects as attributes
the proper model should be...
oh, wait, I see what you did
so, yeah, the error tells you what to do
specify a unique name for each of those enum types, directly
the default behavior for generating type names in XML-land doesn't take into account nested type names in C#-land
thanks, do i specify it against the enum or the property?
not sure
possibly within the
[XmlAttribute]
tag you already have?
otherwise, some new tag on each of the enums themselvesi think it means this:
this does work :)
but that creates another problem, in my application i dont have access to these nested enums, so i need to find a way to apply these TypeNames retroactively
so, these are third-party types you're trying to deserialize?
yes, but for more complex types that dont have [Serializable] i have other solutions, my current blocker is the ambiguous type names
for types that you can't annotate, and that can't just be deserialized by inference, you'll probably be forced to write a custom deserializer or type converter
Hey this works !!! so thats how overrides works, thanks @V.EINA Jaken :)
sweet
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.