-
Notifications
You must be signed in to change notification settings - Fork 334
Add support for array encoding with @encode(ArrayEncoding.*) decorator #9430
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
base: main
Are you sure you want to change the base?
Conversation
|
No changes needing a change description found. |
e7bb9b0 to
fbbfaf5
Compare
...ent-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/InputModelProperty.cs
Show resolved
Hide resolved
...ient-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/PropertyWireInformation.cs
Outdated
Show resolved
Hide resolved
83cc0d8 to
4be7888
Compare
jorgerangel-msft
left a comment
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.
It's good to see the spector tets, but could we also please add some unit tests for the serialization + deserialization code? It would be helpful to see the generated output of that.
...tor/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs
Outdated
Show resolved
Hide resolved
...tor/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs
Outdated
Show resolved
Hide resolved
| // Get the delimiter based on the encoding type | ||
| var delimiter = encoding switch | ||
| { | ||
| "commaDelimited" => ",", |
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.
As Josh pointed out, I think these encoding formats should be an enum type.
...tor/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs
Outdated
Show resolved
Hide resolved
...tor/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs
Show resolved
Hide resolved
...tor/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs
Outdated
Show resolved
Hide resolved
1ddb208 to
b2757da
Compare
This pull request adds support for custom array encoding formats in the C# HTTP client generator, allowing arrays to be serialized and deserialized using delimiters such as comma, space, pipe, or newline. The changes span the model, serialization logic, type conversion, and test coverage to ensure correct handling of these encodings.
Array encoding support
encodeproperty toInputModelPropertyand related types to specify the desired array encoding (e.g.,commaDelimited,spaceDelimited, etc.). This is reflected in the type definitions, model constructors, and JSON serialization/deserialization logic.type-converter.ts) to propagate theencodeproperty from SDK model properties into the input model.Serialization and deserialization logic
MrwSerializationTypeDefinition.csto handle arrays with specified encodings. These methods join or split array elements using the appropriate delimiter and handle both string and primitive element types.Test coverage
EncodeArrayTests.csto verify correct serialization and deserialization for each supported encoding format (comma, space, pipe, newline).Implements: #9028