-
Notifications
You must be signed in to change notification settings - Fork 171
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
Support duration-constant #5269
base: main
Are you sure you want to change the base?
Conversation
@@ -51,7 +51,7 @@ public static InputDurationType CreateDurationType(ref Utf8JsonReader reader, st | |||
crossLanguageDefinitionId = crossLanguageDefinitionId ?? throw new JsonException("Duration type must have crossLanguageDefinitionId"); | |||
encode = encode ?? throw new JsonException("Duration type must have encode"); | |||
wireType = wireType ?? throw new JsonException("Duration type must have wireType"); | |||
|
|||
encode = encode == "duration-constant" ? "constant" : encode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider to combine this to L52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not do it in this way, it would be hard to track these magic values.
Deserialization should just simply do "deserialization" without modification unless we could prove it is absolutely necessary
Therefore here we should deserialize this as is, and if other parts in our generator is expecting constant
instead of duration-constant
, those parts should change accordingly to properly handle duration-constant
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to add something like TryReadEncoding
, but that cannot keep throw new JsonException($"Encoding of Duration type {encode} is unknown.");
. So changed by adding a CreateDurationKnownEncoding
Fix #5261