chore(deps): migrate to JsonSchema.Net 9 - #533
Merged
Merged
Conversation
Three API changes, found by building against 9.4.0 and reading the
compiler rather than guessing:
Evaluate(JsonNode) -> Evaluate(JsonElement)
EvaluationResults.HasErrors -> gone; check Errors is { Count: > 0 }
JsonPointer.Count -> SegmentCount
The JsonElement signature removes a JsonNode.Parse round-trip that only
existed to satisfy the old one. A call carrying no arguments at all
still has to be validated as JSON null rather than skipped — a schema
with required properties must fail when the model sends nothing — so
that case is now an explicit JsonElement holding null, parsed once
because JsonDocument owns unmanaged memory.
That case had no test, which is why it is the one worth adding: it is
the only behaviour of the three that had to be re-expressed rather than
renamed. It fails with `$: Value is "null" but should be "object"` — a
type mismatch at the root, not a missing property, which is the more
accurate complaint since nothing was sent to be missing a property from.
Asserting that string also pins the other two migrations: the "$" comes
from SegmentCount, and reaching the message goes through the Errors
dictionary.
Note for the next person: `dotnet test --no-build` after a package
version change runs the previous binaries. It reported 886 passing here
while the test assembly was still linked against JsonSchema.Net 7, and
the truth only appeared after deleting bin/obj — the stale DLL was from
March.
Verified on a clean build: Release build, dotnet format, 1422 unit tests.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MkGcwmi1fuGCBLmGwdEZ1F
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 freeto 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.
Closes the work #526 was asking for. Three API changes, found by building against 9.4.0 and reading
the compiler rather than guessing at release notes:
Evaluate(JsonNode, …)Evaluate(JsonElement, …)EvaluationResults.HasErrorsErrors is { Count: > 0 }JsonPointer.CountSegmentCountThe
JsonElementsignature removes aJsonNode.Parseround-trip that only existed to satisfy theold one — the arguments arrive as a
JsonElementalready.A call carrying no arguments at all still has to be validated as JSON null rather than skipped: a
schema with required properties must fail when the model sends nothing. That is now an explicit
JsonElementholding null, parsed once and held, becauseJsonDocumentowns unmanaged memory anddoing it per call would leak a document on every tool invocation.
The one case worth a test
That case had none — and it is the only one of the three that had to be re-expressed rather than
renamed, so it is the only one where the migration could silently change behaviour.
It fails with:
A type mismatch at the root rather than a missing property, which is the more accurate complaint —
nothing was sent, so there is no object to be missing a property from. My first assertion looked for
"text"and was simply wrong about what the library should say.Asserting that exact string also pins the other two migrations: the
$comes fromSegmentCount,and reaching the message at all goes through the
Errorsdictionary that replacedHasErrors.A trap worth recording
dotnet test --no-buildafter a package version change runs the previous binaries. It reported886 passing here while the test assembly was still linked against JsonSchema.Net 7 — the DLL in
bin/was dated March. The real result only appeared after deletingbin/obj.That is the same shape as three other things today: green from an artifact that was not the artifact
under test.
Verification
Clean build. Release build succeeds,
dotnet format --verify-no-changesclean, 1422 unit testspass (1421 existing + the new one).
Rollback
Revert.
Directory.Packages.propsgoes back to JsonSchema.Net 7.3.4 andToolDispatcherto theJsonNodepath.🤖 Generated with Claude Code
https://claude.ai/code/session_01MkGcwmi1fuGCBLmGwdEZ1F