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

Support attributes with overrides #555

Open
magneticflux- opened this issue Jan 5, 2025 · 0 comments · May be fixed by #556
Open

Support attributes with overrides #555

magneticflux- opened this issue Jan 5, 2025 · 0 comments · May be fixed by #556

Comments

@magneticflux-
Copy link

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:

magneticflux- added a commit to magneticflux-/CommandLineUtils that referenced this issue Jan 5, 2025
Previously, the property in the base class and the property in the subclass would both be returned, causing us to complain about duplicate arguments/options that are actually the same.

Closes natemcmaster#555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant