Skip to content

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
m_scope = scope;
m_ctor = (RuntimeConstructorInfo)RuntimeType.GetMethodBase(scope, caCtorToken)!;

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

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
Contributor

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