fix(csharp): add precision fallbacks to JsonElementComparer for float/double#14875
Conversation
…tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
SDK Generation Benchmark ResultsComparing PR branch against latest nightly baseline on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
…t precision Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…llback Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
SDK Generation Benchmark ResultsComparing PR branch against latest nightly baseline on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Description
Fixes mock server test failures (e.g.
GetJobPredictionsTest.MockServerTestin the Hume C# SDK) caused by a serialization format mismatch when fields useformat: float.Root cause: When a JSON response contains a float value like
0.10722749680280685, C# deserializes it intoSystem.Single, then re-serializes it usingSystem.Text.Jsonwhich outputs the shortest roundtrip representation:0.1072275. The test comparator (JsonElementComparer) compares viaGetDecimal(), which is string-based, so0.10722749680280685 != 0.1072275and the test fails — even though both represent the same float32 bits.Changes Made
JsonElementComparer.Template.cs, replaced the directGetDecimal()fail with a 3-tier fallback chain:GetDecimal()→GetDouble()→GetSingle(). Only reports a mismatch if all three levels disagree. The intermediateGetDouble()check preventsGetSingle()from masking genuine differences in double-precision fields (e.g. integers16777216vs16777217are equal asSinglebut differ asDouble)2.59.4inversions.ymlJsonElementComparer.csfilesformat: float. TheGetDouble()intermediate check should prevent false positives for double-precision and integer fields, but consider edge cases: if two decimal values differ only beyond double precision (>15 significant digits),GetDouble()would consider them equal and skip theGetSingle()check entirely, which is the correct behavior. However, no test currently exercises any of these fallback paths.Testing
pnpm run check)GetJobPredictionsTest.MockServerTestpasses with this changeLink to Devin session: https://app.devin.ai/sessions/1dcf1274fbe74a7cbac9f76e9a65ed28
Requested by: @Swimburger