Presently, the source generator generates a member for each type.
Would it be practical to instead have a private readonly object? _theObj and instead generate private T{#} _value{#} => Unsafe.As<T{#}>(_theObj) instead so that only one object is stored instead of N?
A downside here is the boxing that using struct instead of class avoids becomes cancelled since value types will have to be boxed to be storable in an object? but the upside is for a large number of objects, less storage is wasted because only the active object is stored instead of default values for all the unused one(s).
Presently, the source generator generates a member for each type.
Would it be practical to instead have a
private readonly object? _theObjand instead generateprivate T{#} _value{#} => Unsafe.As<T{#}>(_theObj)instead so that only one object is stored instead of N?A downside here is the boxing that using struct instead of class avoids becomes cancelled since value types will have to be boxed to be storable in an
object?but the upside is for a large number of objects, less storage is wasted because only the active object is stored instead of default values for all the unused one(s).