Skip to content

Custom "enum" types with a custom type provider #1068

Answered by TristonianJones
davenewza asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @davenewza,

Here are a few tips in no specific order:

  • The cel.Constant call should provide a value associated with the variable and type information.
  • The contract for operator.Equals is T == T, so you don't really need to create a custom overload
  • (reflected in your Gist) Prefer using cel.OpaqueType for a type that has no accessible fields, and cel.ObjectType for a type with accessible fields.
  • Avoid using types.NewNullableType() since null should really only be used for JSON values and in some limited circumstances for well-known protobuf types.

Since Status is an ObjectType, the error messages will be based upon a typed field-access. We can certainly update the error message to indic…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by davenewza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants