Description
Some objects are more object than other. There are classes where we do fiddle with identity, and we don't allow you to use those with features that depend on identity (currently Expando
, Finalizer
and WeakReference
).
The problem so far has been that it's possible to have two separate objects with the same "identity". Even worse, it's possible to reintroduce an identical value after an old object has been GC'ed (for strings). That's such a mess that we just disallowed using those objects in places where identity and GC both matter.
Struct types, with their lax identity requirements, are different. It's not that we can introduce an identical struct later, it's more that we can't even know that we can present the same struct twice. It's a safe and correct implementation to throw away anything attached to a struct with an Expando
immediately, because we don't even promise that the value has the same identity across calling Expando.[]=
.
Should we disallow using struct types with Expando
, Finalizer
and WeakReference
?
(Extension structs do not have their own identity, that belongs to the underlying object, so whatever we do should depend on the wrapped object, not the extension struct type.)