-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Consider all MemberInfo references for IsCollectible #119869
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
Conversation
Use ReflectedType instead DeclaringType since ReflectedType can be colletible even when DeclaringType is not. These fixes support typical IsCollectible use case where the property is used to determine whether or how the reflection objects can be cached. Fix dotnet#119697
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.
Pull Request Overview
This PR fixes the IsCollectible property implementation across various reflection member types to use ReflectedType instead of DeclaringType when determining collectibility. This ensures proper caching behavior in scenarios where the reflected type can be collectible even when the declaring type is not collectible.
Key changes:
- Updated
IsCollectibleproperty implementations inRuntimePropertyInfo,RuntimeFieldInfo,RuntimeEventInfo, andRuntimeConstructorInfoto useReflectedTypeInternal.IsCollectible - Enhanced
RuntimeMethodInfo.IsCollectibleto check both reflected type and method handle collectibility - Refactored test methods from theory-based to fact-based tests that iterate through all members
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| RuntimePropertyInfo.cs | Changed IsCollectible to use ReflectedTypeInternal instead of m_declaringType |
| RuntimeMethodInfo.CoreCLR.cs | Added check for ReflectedTypeInternal.IsCollectible before existing method handle check |
| RuntimeFieldInfo.cs | Changed IsCollectible to use ReflectedTypeInternal instead of m_declaringType |
| RuntimeEventInfo.cs | Changed IsCollectible to use ReflectedTypeInternal instead of m_declaringType |
| RuntimeConstructorInfo.CoreCLR.cs | Changed IsCollectible to use ReflectedTypeInternal instead of m_declaringType |
| IsCollectibleTests.cs | Refactored from theory-based tests to comprehensive fact-based tests iterating through all members |
|
Tagging subscribers to this area: @dotnet/area-system-reflection |
MemberInfo can reference multiple different assemblies (e.g. via generic instantiation or via reflected type). IsCollectible property must take all references into account. Related to dotnet/runtime#119869
|
Also, I have submitted clarification for the docs repo: dotnet/dotnet-api-docs#11825 |
…otnet#119869) Use ReflectedType instead DeclaringType since ReflectedType can be colletible even when DeclaringType is not. These fixes support typical IsCollectible use case where the property is used to determine whether or how the reflection objects can be cached. Fix dotnet#119697
Use ReflectedType instead DeclaringType since ReflectedType can be colletible even when DeclaringType is not. These fixes support typical IsCollectible use case where the property is used to determine whether or how the reflection objects can be cached. Fix dotnet#119697
MemberInfo can reference multiple different assemblies (e.g. via generic instantiation or via reflected type). IsCollectible property must take all references into account. Related to dotnet/runtime#119869
Use ReflectedType instead DeclaringType since ReflectedType can be colletible even when DeclaringType is not.
These fixes support typical IsCollectible use case where the property is used to determine whether or how the reflection objects can be cached.
Fix #119697