OneOf
OneOf copied to clipboard
Please can you add a source generator for value typed OneOf?
It would be great to have OneOf source generators for struct.
Something like:
[GenerateOneOf(typeof(String), typeof(Int)]
public readonly partial struct MyStruct {}
public readonly partial struct MyStruct {
private readonly String _value0;
private readonly Int _value1;
private readonly int _index;
public IsString => ...
public IsInt => ...
public string AsString => ...
public int AsInt => ...
}
This looks close to how I built my union library https://github.com/AterraEngine/unions-cs as it is fully built on using ValueTypes. There is a lot of performance gained with how I approached it, maybe something OneOf can definitly implement?