You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've done this more than a few times now (love this library!), so it would be really nice to have a shorthand that just generates the cast. Something like [GenerateOneOfImplicitCastAttribute<PartialOutcome>] (Now that we have generic attributes!)
This should of course only work if the type cast from's generic types are all contained in the cast to's generic types
I'd write it myself, but source generators still bend my mind for the time being.
The text was updated successfully, but these errors were encountered:
This is particularly useful when when using option types, for example
[GenerateOneOf]
public partial class StringOrNumber : OneOfBase<string, int> { }
StringOrNumber myString = "My String"; // this compiles
StringOrNumber myNumber = 2; // this compiles
OneOf<StringOrNumber, None> foo = 3; // this does NOT compile
OneOf<StringOrNumber, None> bar = "hello world"; // this does NOT compile
Considder the following code:
To remedy the error, one can add to
RealOutcome
the following boilerplate method:I've done this more than a few times now (love this library!), so it would be really nice to have a shorthand that just generates the cast. Something like
[GenerateOneOfImplicitCastAttribute<PartialOutcome>]
(Now that we have generic attributes!)This should of course only work if the type cast from's generic types are all contained in the cast to's generic types
I'd write it myself, but source generators still bend my mind for the time being.
The text was updated successfully, but these errors were encountered: