Wire: write doubles and floats with .NET Framework's round-trip digits

The original ran Newtonsoft.Json on .NET Framework, whose "R" format writes
15 significant digits when they read back exactly and 17 otherwise (floats: 7,
else 9). Modern .NET writes the shortest round trip instead, so a value like
-0.066666670143604279 came out as -0.06666667014360428: equal when parsed,
different bytes. Every frame now goes through a converter that repeats the
Framework rule, with Newtonsoft's '.0' suffix and non-finite handling kept.
Goldens that encoded the modern digits are corrected.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-09-25 12:44:34 +02:00
parent 82a518dcfb
commit 5a94e1cf0b
7 changed files with 148 additions and 7 deletions

View file

@ -83,8 +83,8 @@ public sealed class VitalSharingTests
Feature(harness).OnTick();
string ew = Math.Round((double)33.65f, 7).ToString("R", CultureInfo.InvariantCulture);
string ns = Math.Round((double)42.55f, 7).ToString("R", CultureInfo.InvariantCulture);
string ew = OpenAC.MosswartMassacre.Backend.FrameworkNumberConverter.FrameworkRoundTrip(Math.Round((double)33.65f, 7));
string ns = OpenAC.MosswartMassacre.Backend.FrameworkNumberConverter.FrameworkRoundTrip(Math.Round((double)42.55f, 7));
Assert.Equal(
[
"{\"type\":\"share_vital_update\",\"timestamp\":\"" + Stamp + "\",\"character_name\":\"Mossy\","