SteveDunn / Vogen

A semi-opinionated library which is a source generator and a code analyser. It Source generates Value Objects
Apache License 2.0
887 stars 46 forks source link

Bug in System.Text.Json number handling #595

Closed SteveDunn closed 6 months ago

SteveDunn commented 6 months ago

The generated code for reading a value uses options.NumberHandling == global::System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString to check if reading from strings is enabled. However JsonNumberHandling is a [Flags] enum and therefore this fails if multiple options are set (e.g. NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString).

This was originally raised by @MGRatEJOT

SteveDunn commented 6 months ago

I don't that fixing this will be a breaking change because there should be nothing out there serialized as a string and hence failing the incorrect reading logic (the reading logic currently says 'if it is exactly 'allow reading from string' and the token is a string).

SteveDunn commented 6 months ago

Fixed in 4.0.5