-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Conversation
- 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
src/tests/reflection/GenericAttribute/GenericAttributeMetadata.il
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs
Outdated
Show resolved
Hide resolved
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Fixes #56492