Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider allowing XML generic type resolution of TypeMapping properties declared outside of core operators #1277

Closed
glopesdev opened this issue Mar 9, 2023 · 1 comment · Fixed by #1279
Labels
proposal Request for a new feature
Milestone

Comments

@glopesdev
Copy link
Member

Currently arbitrary XML generic type serialization is limited only to core operators. Specific types such as TypeMapping can be useful outside the core to target generic types, however they currently cannot be so used because of an enforced feature-lock requiring them to be placed in properties with the default XML namespace:

var lookupTypes = elementNamespace == Constants.XmlNamespace;

If this test was extended even just slightly to check for generic TypeArguments attributes with the default type, regardless of the namespace of the element where they are placed, this would allow for much more powerful XML serialization strategies.

Care should be considered to ensure that conflicting serialization directives are not introduced by third-party types used this way.

@glopesdev glopesdev added the proposal Request for a new feature label Mar 9, 2023
@glopesdev glopesdev added this to the 2.8 milestone Mar 10, 2023
@glopesdev
Copy link
Member Author

glopesdev commented Mar 10, 2023

Attribute properties of concrete class types serialized using xsi:type do not require the use of explicit namespaces. For example in the following:

<Combinator xsi:type="p1:CustomType" MyProperty="42" />

The attribute MyProperty is implicitly assumed to be under the same namespace p1 as CustomType.

This is problematic for reusing more broadly the existing generic type serialization strategies, since the TypeArguments attribute used e.g. in TypeMapping is always assumed to be used without prefix, i.e. it assumes that TypeArguments is a proper attribute of the generic type. This can work for generic types which are under the control of the core assembly, but would result in a name clash when serializing generic types containing themselves a property called TypeArguments.

Because of this, it is indeed best if this functionality is not extended too broadly. In the future we may want to revisit the entire topic of serialization and language models but for now, and in order to keep required modifications to a minimum, we should probably restrict the usage of serialized generic properties to known types, such as TypeMapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant