Skip to content

Support attributes with overrides #555

@magneticflux-

Description

@magneticflux-

I'm updating an application that used a version of CommandLineUtils from before b92f20e, and it correctly handled attribute overrides through the built-in [AttributeUsage(Inherited = true)] system (an attribute present on a subclass would completely replace one on the superclass). Now, I get a duplicate attribute error because the same property is detected and returned twice, from the subclass and the superclass.

More specifically, the patch needs to iterate over each BaseType (walking up the class hierarchy) to find private members because they are not included in subtype.GetProperties(BindingFlags.NonPublic). The author included the additional flag BindingFlags.DeclaredOnly to fix the obvious issue with inheritance (the method would return spurious duplicate members on all inherited classes), but missed the case where the subclass is overriding something that is declared in both classes - in which case we should only take the most specific instance.

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions