mknejp / dotvariant

A type-safe and space-efficient sum type for C# (comparable to discriminated unions in C or C++)
https://twitter.com/mknejp
70 stars 3 forks source link

Generics support #20

Closed ajdean closed 2 years ago

ajdean commented 3 years ago

Hi,

Is it currently possible to create a variant with a generic parameter? e.g.

[Variant]
public partial struct Result<T>
{
    static partial void VariantOf(T success, string[] errors);
}

Currently I'm getting the following error when I try:

Generator 'SourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName contains an invalid character '<' at position 22. (Parameter 'hintName')'

Thanks.

mknejp commented 3 years ago

Not right now, but it's on my TODO list

mknejp commented 2 years ago

Support for generic types is now available in version 0.5.0.

mknejp commented 2 years ago

Please let me know if you encounter any issues!