[release/10.0] Consider all MemberInfo references for IsCollectible (#119869) #119911
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #119869 to release/10.0
Customer Impact
Unable to unload collectible assemblies after calling framework APIs that cache certain reflection MemberInfos. Fix #119697.
MemberInfo.IsCollectible is frequently used to determine whether the reflection objects can be cached unconditionally. It was returning wrong result (false instead of true) for shared generic methods and more specialized reflected types, that in turn caused the MemberInfo to be cached unconditionally and prevented unloading of collectible assemblies that it referenced.
Regression
Testing
New tests added to exercise the fixed behavior
Risk
Low