Repository navigation
[C#] Correct index consumption in dynamic-model collection patch paths - #12437
Merged
Jorge Rangel (jorgerangel-msft) merged 3 commits intoOct 29, 2026
Merged
Jorge Rangel (jorgerangel-msft) merged 3 commits into
Jorge Rangel (jorgerangel-msft) merged 3 commits into
Conversation
|
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. |
Co-authored-by: jorgerangel-msft <[email protected]>
Copilot
AI
changed the title
[WIP] Fix incorrect bytesConsumed in TryGetIndex for nested JsonPatch
[C#] Correct index consumption in dynamic-model collection patch paths
Oct 29, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the collection-path forwarding fix.
No open issues 🎉
What changed in this PR
This PR fixes collection-path forwarding in generated C# dynamic models, addressing #12431 so nested JsonPatch reads and writes receive the correct child path.
Changes:
- Count both brackets in successful
TryGetIndexconsumption while preserving parse-failure behavior. - Update the generated sample and helper baseline.
- Add regression tests for index parsing and parent-to-child patch propagation through single and nested collections.
| File | Description |
|---|---|
packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs |
Updates the generated helper’s consumed-byte count. |
packages/http-client-csharp/generator/TestProjects/Local.Tests/ModelSerializationExtensionsTests.cs |
Tests valid indices, remaining paths, and invalid inputs. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/Definitions/TestData/ModelSerializationExtensionsDefinitionTests/ValidateTryGetIndex.cs |
Updates the expected generated helper baseline. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/ModelReaderWriterValidation/TestProjects/Sample_TypeSpec/DynamicModelTests.cs |
Tests collection-based patch reads and writes with single- and multi-digit indices. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs |
Emits the bracket-inclusive consumed-byte count after successful parsing. |
Review effort: Balanced
commit: |
Jorge Rangel (jorgerangel-msft)
marked this pull request as ready for review
October 29, 2026 15:41
Jorge Rangel (jorgerangel-msft)
requested review from
JoshLove-msft,
Alan Zimmer (alzimmermsft),
Jose Arriaga Maldonado (joseharriaga) and
m-nash
as code owners
October 29, 2026 15:41
Jorge Rangel (jorgerangel-msft)
approved these changes
Oct 29, 2026
Alan Zimmer (alzimmermsft)
approved these changes
Oct 29, 2026
Co-authored-by: jorgerangel-msft <[email protected]>
Jorge Rangel (jorgerangel-msft)
approved these changes
Oct 29, 2026
JoshLove-msft
approved these changes
Oct 29, 2026
Jorge Rangel (jorgerangel-msft)
deleted the
copilot/fix-incorrect-bytesconsumed-issue
branch
October 29, 2026 22:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated
TryGetIndexcounts only index digits, but collection propagators slice past the entire[index]segment. This forwards malformed child paths and breaks nestedJsonPatchreads and writes.bytesConsumed; preserve parse-failure behavior.