icerpc / icerpc-csharp

A C# RPC framework built for QUIC, with bidirectional streaming, first-class async/await, and Protobuf support.
https://docs.icerpc.dev
Apache License 2.0
108 stars 13 forks source link

Remove Discriminant property in generated enum with fields #3870

Closed bernardnormier closed 11 months ago

bernardnormier commented 11 months ago

We currently generate a public Discriminant property in the base record class for enum with fields.

I propose to remove this property, but keep the public Discriminant const in the known enumerators and the Discriminant property in the Unknown enumerator (for unchecked enum).

For "int" enum, the int value of the enumerator is naturally important. However, for enum with fields, it's just an encoding detail. While it's doable to expose this value in C# (as currently done), we probably can't do this as cleanly in other languages. These discriminants are also comparable to tag values, and we currently don't provide any way for a C# applications to retrieve these tag values.