Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please can you add a source generator for value typed OneOf? #177

Open
jamescarter-le opened this issue Jul 22, 2024 · 1 comment
Open

Comments

@jamescarter-le
Copy link

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 => ...
}
@AnnaSasDev
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants