-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type of model property/enum member when it is defined as constant number #3314
Comments
This is the C# syntax.
enum LongValueEnum: long
{
A = 100000000000000000,
B = 2,
}
enum IntValueEnum
{
A = 2,
B = 8,
} |
Like other languages, literal values without specific identifier (e.g. I think there are two strategies:
Personally, I perfer the 2nd strategy, because TypeSpec is used to represent both client side and server side. It would be weird if the data types for the server side depends on the languages implementing the service. |
Unlike .Net, Java client's current behavior is to use |
from typespec compiler, we just get an number value. in tcgc, we will type them with |
@tadelesh We think the right thing here is to have a default behavior in the emitter and add an emitter decorator that allows specifying a preferred client representation type, for emitters where that makes sense. So, I think we want to move this issue into the Azure repo, or manage is as an emitter-specific issue for client emitters here. |
Can we document the decision for the types of literal value? Then I think we can close this issue. |
Hi @haolingdong-msft. Since there hasn't been recent engagement, we're going to close this out. Please feel free to reopen if you have any further questions or concerns. |
TSP:
For model property/enum member defined as constant number, in above example,
Operation.age
,Property.High
,Priority.Low
, how to interprete the type of the property/enum member? Should it beint32
orint64
?If it is interpreted as
int32
, in the future, if anotherint64
enum value added, or the model property is set to aint64
number, it would be breaking changes for Java and .Net client code, as the type changed fromint
tolong
.If it is interpreted as
int64
, then we should make sure service understand this and can handle when user passeslong
value.To solve this:
int32
orint64
. Avoid the definition likeage: 50
as this is ambiguous.Would like to hear your thoughts and suggestions, Thanks.
The text was updated successfully, but these errors were encountered: