-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add cast to ComAwareWeakReference rehydrate path #119132
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
Prevents hard to diagnose crashes caused by COM interop rehydrating wrong type.
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 addresses COM interop type safety issues by adding explicit casting during the weak reference rehydration process. The changes prevent hard-to-diagnose crashes that can occur when COM interop rehydrates objects to the wrong type.
Key Changes:
- Modified the COM-aware weak reference rehydration path to include runtime type casting
- Refactored
ComAwareWeakReferenceto expose the rehydration method with generic type parameter - Updated both generic and non-generic
WeakReferenceclasses to use the new type-safe rehydration approach
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/libraries/System.Private.CoreLib/src/System/WeakReference.cs |
Updated non-generic WeakReference to use new type-safe COM-aware rehydration with explicit object casting |
src/libraries/System.Private.CoreLib/src/System/WeakReference.T.cs |
Updated generic WeakReference to use new type-safe COM-aware rehydration with explicit T casting |
src/libraries/System.Private.CoreLib/src/System/ComAwareWeakReference.cs |
Refactored to expose generic RehydrateTarget method with runtime casting and consolidated access through GetFromTaggedReference |
|
Tagging subscribers to this area: @dotnet/interop-contrib |
src/libraries/System.Private.CoreLib/src/System/ComAwareWeakReference.cs
Show resolved
Hide resolved
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17267267126 |
Prevents hard to diagnose crashes caused by COM interop rehydrating wrong type.