Skip to content

Fix C# integer mappings and serialization - #12283

Merged
Jorge Rangel (jorgerangel-msft) merged 2 commits into
mainfrom
copilot/address-pr-comment-issue
Oct 15, 2026
Merged

Jorge Rangel (jorgerangel-msft) merged 2 commits into
mainfrom
copilot/address-pr-comment-issue

Conversation

Copilot AI commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Missing integer mappings caused uint32[] to generate IList<object>, requiring custom SDK wrappers. This change preserves numeric types and fills the corresponding serialization gaps.

  • Type mappings: Map int16, uint16, uint32, and uint64 to short, ushort, uint, and ulong, including nullable types and collections.
  • Serialization: Support unsigned JSON numbers and string encoding, numeric collection request bodies, and lossless ulong XML writes.

For a TypeSpec property declared as bottom_right: uint32[], generate:

public IList<uint> BottomRight { get; }

rather than IList<object>.

Copilot AI and others added 2 commits October 15, 2026 18:54
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…paths

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@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 Oct 15, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI changed the title fix(http-client-csharp): preserve integer types in generated clients Fix C# integer mappings and serialization Oct 15, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@12283

commit: a73e87c

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Numeric collection support remains incomplete in request serialization and response deserialization.

2 open findings
What changed in this PR

Fixes C# integer mappings so generated SDKs preserve numeric types instead of using object.

Changes:

  • Maps four integer types to their C# equivalents.
  • Adds unsigned JSON serialization and lossless ulong XML writes.
  • Updates tests and generated baselines.
File Description
packages/​http-client-csharp/​generator/​TestProjects/​Spector/​http/​encode/​numeric/​src/​Generated/​Models/​Uint32AsStringProperty.cs Uses nullable uint.
packages/​http-client-csharp/​generator/​TestProjects/​Spector/​http/​encode/​numeric/​src/​Generated/​EncodeNumericModelFactory.cs Updates factory parameter type.
packages/​http-client-csharp/​generator/​TestProjects/​Spector.Tests/​Http/​Encode/​Numeric/​EncodeNumericTests.cs Checks typed numeric values.
packages/​http-client-csharp/​generator/​TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Internal/​ModelSerializationExtensions.cs Regenerates integer serialization cases.
packages/​http-client-csharp/​generator/​TestProjects/​Local.Tests/​ModelSerializationExtensionsTests.cs Tests integer range boundaries.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator/​test/​TypeFactoryTests.cs Tests primitive and collection mappings.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator/​src/​TypeFactory.cs Adds missing integer mappings.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​XmlSerializationTests.cs Tests integer XML writes.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​MrwSerializationTypeDefinitionTests.cs Expands integer serialization tests.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​Definitions/​TestData/​ModelSerializationExtensionsDefinitionTests/​ValidateWriteObjectValueXmlIncludesFileBinaryContentCase.cs Updates serialization baseline.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​Definitions/​TestData/​ModelSerializationExtensionsDefinitionTests/​ValidateWriteObjectValueIncludesFileBinaryContentCase.cs Updates serialization baseline.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Snippets/​JsonElementSnippets.cs Adds unsigned JSON getters.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​MrwSerializationTypeDefinition.Xml.cs Preserves ulong XML precision.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​MrwSerializationTypeDefinition.cs Supports unsigned JSON deserialization.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ModelSerializationExtensionsDefinition.cs Adds integer object-write cases.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Merged via the queue into main with commit c74e373 Oct 15, 2026
34 checks passed
@jorgerangel-msft
Jorge Rangel (jorgerangel-msft) deleted the copilot/address-pr-comment-issue branch October 15, 2026 22:13
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.

5 participants