Repository navigation
fix: Use decimal literals for tax rate and coordinates - #242
Conversation
Casting a double literal to decimal, e.g. (decimal?)0.2, gives the exact binary value when compiled with the .NET 11 SDK, whatever the target framework. The tax rate became 0.2000000000000000111, so B failed with TotalPaymentDueMismatchError in the tax-calculation-net tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A note on the two These jobs run the test suite against the .NET Framework example ( So the .NET Framework example has had no CI coverage since mid-2025. This PR changes its two store files in the same way as the .NET Core ones ( I'll raise a separate PR or issue to either move these jobs to |
The OpenActive Test Suite has failed in random mode since GitHub's ubuntu-22.04 runner image 20261111 (first seen on 18 November). 98 tests fail, all in
business-to-business-tax-calculation-netandbusiness-to-consumer-tax-calculation-net. B is rejected with:This affects every repo that runs the test suite against this reference implementation, including data-models and data-model-validator.
Cause
The workflow installs SDK 3.1.419, but
dotnet builduses the newest SDK already on the runner. On 12 November that was 10.0.403. The new runner image has 11.0.100..NET 11 changed double-to-decimal conversion so that it converts the exact binary value: Decimal and BigInteger floating-point conversions are correctly rounded. This applies to constants too:
So
(decimal?)0.2now compiles to 0.2000000000000000111. On a price of 7.79, that gives exactly the 9.348000000000000086486373619 in the error.Change
Replaces the
(decimal?)double-literal casts with decimal literals, as Microsoft recommends:(decimal?)0.2to0.2M, inSessionStore.csandFacilityStore.cs, in both the AspNetCore and AspNetFramework examples.FeedGenerationHelper.cs, for example(decimal?)51.7502to51.7502M. These would otherwise appear in the feeds with long values, such as 51.75019999999999953388396534 (the exact binary value, rounded to 28 significant digits).(decimal)0.5inFakeBookingSystem.csis unchanged, because 0.5 is exact in binary.Testing
BookingSystem.AspNetCoreandBookingSystem.AspNetCore.IdentityServerin Release with SDK 8. Both have 0 errors, and the warnings are identical to master.Follow-up, not in this PR
Builds will keep using whichever SDK is newest on the runner. Pinning the SDK (a
global.json, or the build step in the test suite workflow) would stop runner image updates changing behaviour silently. Buildingnetcoreapp3.1with SDK 3.1 may need its own changes, so I've left it for a separate PR.