fix(opl): only apply the ':#' cliloc marker to integer values (#2540)

`ObjectPropertyList.AppendFormatted<T>(value, format)` treated **any** `{value:#}` as the cliloc marker (emitting `#<value>`). But cliloc numbers are integers — a `float`/`double`/`decimal` formatted with `#` is the standard custom-numeric (`#` = digit placeholder) format, not a cliloc reference, so those were being mis-marked.

Gate the marker on an integer value type:
```csharp
if (format == "#" && value is int or uint or long or ulong or short or ushort or byte or sbyte)
```

Now `{someFloat:#}` formats normally (passes `#` through to `TryFormat`); the marker/standard-format ambiguity narrows to the harmless `{0:#}` **integer** case (`#0`). Existing `AddLocalized(int)` / `{value:#}` (all `int`) are unaffected.

Adds `ObjectPropertyListSpanAddTests.HashFormat_OnlyMarksIntegers`: `int {value:#}` → `#<value>`; `double {value:#}` → `42.0.ToString("#")` (`"42"`, no `#`).
This commit is contained in:
Kamron Batman 2026-07-19 10:49:16 -07:00 committed by GitHub
parent 8d88ef70fd
commit 858c1d18bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View file

@ -384,9 +384,9 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
public void AppendFormatted<T>(T value, string? format)
{
// We support localization '#' cliloc formatter for custom property lists
// This allows someone to build an IPropertyList that creates HTML using the same syntax as LocalizationInterpolationHandler
if (format == "#")
// '#' marks an integer argument as a cliloc ("#<value>"). Integers only -- a float/double/decimal
// '#' is the standard numeric format, not a cliloc marker.
if (format == "#" && value is int or uint or long or ulong or short or ushort or byte or sbyte)
{
AppendLiteral("#");
format = null;