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

SearchableAttribute creating duplicate instances of attributes on nested types #23

Open
Priscillalala opened this issue Jan 17, 2024 · 0 comments

Comments

@Priscillalala
Copy link
Contributor

SearchableAttribute first searches every type in the assembly for the attribute, this includes nested types. Then, it searches the members of each type, which includes nested types. As a result, a SearchableAttribute applied to a nested type will be included in the instancesList twice.

For example, in this case:

    public class TestAttribute : HG.Reflection.SearchableAttribute { }

    public class Outer
    {
        [TestAttribute]
        public class Inner { }
    }

A call to SearchableAttribute.GetInstances() should return a list with 1 element, but the list instead contains 2 TestAttributes that target Inner.

As far as I know this affects nothing in vanilla, but can cause unintended behaviour for modders.

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

No branches or pull requests

1 participant