XamlX
XamlX copied to clipboard
Support for overriding Content attribute in derived classes
Hi, thank you for this library. Consider the following situation:
class Base
{
[Content]
public Base[] BaseProp { get; }
}
class Derived : Base
{
[Content]
public Base[] DerivedProp { get; }
}
With this code I would like to override the "content" property in Derived
class to use DerivedProp
instead of BaseProp
.
Then when parsing the following XAML:
<Derived>
<Base />
<Base />
</Derived>
I get error: XamlX.XamlTypeSystemException: 'Content (or substitute) attribute is declared on multiple properties of Derived'
Commenting the following code here:
if (GetCustomAttribute(p, TypeMappings.ContentAttributes).Any())
{
//if (found != null && !p.Equals(found))
// throw new XamlTypeSystemException(
// "Content (or substitute) attribute is declared on multiple properties of " + type.GetFqn());
found = p;
}
seems to solve this problem for me.
Maybe there is a different better way to achieve this? If not, should we cover this case in the library? I can submit a PR if needed.