Skip to content

Conversation

@radhgupta
Copy link
Member

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

  • Introduced an optional encode property to InputModelProperty and 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.
  • Updated the type converter (type-converter.ts) to propagate the encode property from SDK model properties into the input model.

Serialization and deserialization logic

  • Added custom serialization and deserialization methods in MrwSerializationTypeDefinition.cs to 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

  • Added new tests in EncodeArrayTests.cs to verify correct serialization and deserialization for each supported encoding format (comma, space, pipe, newline).

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jan 21, 2026
@github-actions
Copy link
Contributor

No changes needing a change description found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant