-
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
Avoid GetConstructors in constraint validation #81068
Conversation
Avoids bringing ConstructorInfo to simple apps.
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
Do simple apps call MakeGenericType? Or is the constraint validation brought in through other paths as well? |
It's through the type resolution logic. We keep fields, including the ability to get/set them (due to the use in Attribute.GetHashCode/Equals). The field type could be generic. We need to call into the type loader to resolve the generic type in the signature. This does a constraint check. |
We assume that the program is valid. Would it be better to omit the constraint check completely in this case? |
This reverts commit 4da12e9.
Done, looks better! |
...eflection.Execution/src/Internal/Reflection/Execution/ReflectionDomainSetupImplementation.cs
Show resolved
Hide resolved
|
||
internal static RuntimeConstructedGenericTypeInfo GetRuntimeConstructedGenericTypeInfoNoConstraintCheck(RuntimeTypeInfo genericTypeDefinition, RuntimeTypeInfo[] genericTypeArguments) | ||
{ | ||
RuntimeTypeHandle precomputedTypeHandle = GetRuntimeTypeHandleIfAny(genericTypeDefinition, genericTypeArguments, ReflectionCoreExecution.ExecutionEnvironment.TryGetConstructedGenericTypeForComponentsNoConstraintCheck); |
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.
Does Roslyn generate delegate cache for this pattern? If not, it would be nice to tweak this to make the delegate cached.
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.
😲 assumed it did, I was wrong. But I understand why. Fixed.
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.
Yes, this looks better. LGTM modulo comment.
Contributes to #80165.
Avoids bringing ConstructorInfo to simple apps.
This and whatever we do for #80896 is all that's left.
Cc @dotnet/ilc-contrib