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
Some idea is to have choice type the same way as value tuples, where first item points to metadata (in this case pointing to choice type metadata) which is a static property on the library, and the second item will be the object value of the choice instance.
where CqlChoiceMetadata is a static property on the library it is returned from, lib in this case.
The tricky part is how to build an expression tree in the ExpressionBuilder with a type that can carry all the choice type possibilities, before it gets processed into simpler C# above. An early spike PR into this demonstrates some issues already PR #608 :
Trying to use a generic type CqlChoiceValue<T1,....T7, TRest> is one way to carry all the types, however, it happens where a method returns a choice with more choices to a variable with less choices, then CqlChoiceValue<a,b,c> isn't compatible with CqlChoiceValue<a,b>. Some additional logic is needed to check compatibility and to copy the object value from the one into the other
Trying to make a custom type CqlChoiceType is hard to implement. Having trouble generating expression trees using this.
Type pattern matching on choice type
Generated C# will emit a switch expression using type pattern matching.
Early concept PR #577
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Declaring a variable to hold a choice type
Some idea is to have choice type the same way as value tuples, where first item points to metadata (in this case pointing to choice type metadata) which is a static property on the library, and the second item will be the object value of the choice instance.
Choice type in c#
where CqlChoiceMetadata is a static property on the library it is returned from,
lib
in this case.The tricky part is how to build an expression tree in the
ExpressionBuilder
with a type that can carry all the choice type possibilities, before it gets processed into simpler C# above. An early spike PR into this demonstrates some issues already PR #608 :CqlChoiceValue<T1,....T7, TRest>
is one way to carry all the types, however, it happens where a method returns a choice with more choices to a variable with less choices, thenCqlChoiceValue<a,b,c>
isn't compatible withCqlChoiceValue<a,b>
. Some additional logic is needed to check compatibility and to copy the object value from the one into the otherCqlChoiceType
is hard to implement. Having trouble generating expression trees using this.Type pattern matching on choice type
Generated C# will emit a switch expression using type pattern matching.
Early concept PR #577
Beta Was this translation helpful? Give feedback.
All reactions