Add support for multiple managed instances for the same native handle
- Dominant language
- C#
- Stars
- 2.9k
- Forks
- 576
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Currently our runtime will try its best to make sure there's only a single managed instance for each native handle, and this is assumed in several places in the code base.
Unfortunately, we break this assumption ourselves in a couple of places:
* We may create an instance of a protocol wrapper type when there's already a managed instance, but when that managed instance doesn't implement the desired protocol interface.
* We may re-create a new managed instance when forcing a particular managed type (see #7441 and the corresponding fix).
We might have to add complete support for having multiple managed instances for the same native handle.
This would probably mean we'd have to make our IntPtr->INativeObject dictionary an IntPtr->List\ dictionary instead. There could be one "main" mapping (whose managed type is determined by the runtime type of the native object, and returned when the caller doesn't know the managed type it wants - Runtime.GetNSObject), and then a list of other instances where the managed type is of a particular type.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.