Skip to content

Memory: .NET does not support generic types with explicit layout. #2

@az-raven

Description

@az-raven

This seems like a glaring flaw in the runtime, and prevents TaggedUnion<A, B, ...> and Union<A, B, ...>. Unfortunately, this restriction occurs as a runtime error, so I was not aware of it until now.

While it's technically possible to get around this using our Bytes API and a fixed-size byte array, this incurs both a marshaling cost as well as the necessity of a heap allocation, which ruins the point of a Union.

For that reason, it's probably worthwhile to remove the Union struct for now, at least until a reasonable implementation can be found. If you have a way to inline a byte array of potentially varying size into a struct, please let me know.

In the meantime, Union and TaggedUnion will remain broken, until they are removed or fixed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions