You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enum format strings are ignored on .NET 8 or later #34
On .NET 8 or later, Utf8StringWriter ignores the format string of enum values and always writes the name, so {x:D} writes Friday instead of 5. DefaultInterpolatedStringHandler, which C# uses for interpolated strings converted to string, writes the underlying value, as x.ToString("D") does.
We found this in ZLogger: the UTF-8 output of [ZLoggerMessage] methods writes {x:D} as the name, while their message string writes the value. ZLogger works around it for ZLog in Cysharp/ZLogger#260.
Environment
Utf8StringInterpolation 1.3.2 (the net8.0 build), .NET SDK 11.0.100, Windows 11.
AppendFormattedCore passes enum values to AppendEnum, which receives the format but writes the value through an interpolated string whose hole has no format:
I checked that this compiles for an unconstrained T and writes Friday, 5, 00000005, and 10 for Friday with no format, D, and X, and for (DayOfWeek)10 with no format. The handler has to be created again for each attempt when dest grows.
Activity