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

Fix CustomAttributeData in the presence of generic attributes #56879

Merged
merged 3 commits into from
Aug 5, 2021

Conversation

davidwrighton
Copy link
Member

Fixes #56492

- Generic attributes need to force the actual exact method to be loaded not just the canonical scenario
- GenericAttribute testing had been disabled due to dotnet/msbuild#6734
- Move GenericAttribute test project to Pri0 as its the only generic custom attribute runtime testing that will occur before .NET 6.0 ships
@@ -273,6 +273,13 @@ private RuntimeCustomAttributeData(RuntimeModule scope, MetadataToken caCtorToke
m_scope = scope;
m_ctor = (RuntimeConstructorInfo)RuntimeType.GetMethodBase(scope, caCtorToken)!;

if (m_ctor!.DeclaringType!.IsGenericType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think the ! is needed for m_ctor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears this is optimized for the non-generic case, since in the generic case we re-set m_ctor. However, without measuring perf, the current approach might be better than getting the "is generic" information from scope.ResolveType(...).IsGenericType and only setting m_ctor once.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, this is optimized for the non-generic case, and is probably non-ideal for the generic case. OTOH, the non-generic case is the perf critical case, so this should be a pretty good result.

@davidwrighton davidwrighton merged commit 019d778 into dotnet:main Aug 5, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 7, 2021
@davidwrighton davidwrighton deleted the fix_56492 branch April 13, 2023 18:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Cannot reflect on generic attributes whose constructors original definition uses type parameters
3 participants