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

GetArguments() doesn't return anything for AttributeUsageAttribute #15

Open
asklar opened this issue Aug 7, 2021 · 2 comments
Open

Comments

@asklar
Copy link
Contributor

asklar commented Aug 7, 2021

I have an attribute and I want to reflect over its AttributeUsage attribute
However when I get the AttributeUsageAttribute instance, doing GetArguments(,) returns no fixed nor named args.

@asklar
Copy link
Contributor Author

asklar commented Aug 7, 2021

I think the fix is to add a FakeType resolver for System.Runtime to mscorlib:

            loadContext.FakeTypeRequired += (sender, e) =>
            {
                var ctx = sender as MrLoadContext;
                if (e.AssemblyName == "Windows.Foundation.FoundationContract" || e.AssemblyName == "Windows.Foundation.UniversalApiContract")
                {
                    e.ReplacementType = ctx.GetTypeFromAssembly(e.TypeName, "Windows");
                }
                else if (e.AssemblyName == "System.Runtime")
                {
                    e.ReplacementType = ctx.GetTypeFromAssembly(e.TypeName, "mscorlib");
                }
            };

@MikeHillberg
Copy link
Owner

Do you have an example winmd/assembly? System.Runtime in .Net Framework is confusing because it's split across two DLLs (System.Runtime and mscorlib).

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

2 participants