Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

pshao25
Copy link
Member

@pshao25 pshao25 commented Mar 18, 2025

Fix #5261

@@ -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;
Copy link
Member

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

Copy link
Member

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.

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support duration-constant
3 participants