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

@ -62,6 +62,21 @@ public class ObjectPropertyListSpanAddTests
Assert.Equal((1070722, "Custom"), entries[0]);
}
[Fact]
public void HashFormat_OnlyMarksIntegers()
{
// Integer {value:#} emits the cliloc marker "#<value>".
var intList = new ObjectPropertyList(null);
intList.Add(1062028, $"{1043009:#}");
Assert.Equal((1062028, "#1043009"), Decode(intList)[0]);
// Float {value:#} is the standard '#' custom-numeric (digit-placeholder) format, not a cliloc
// marker -- so no leading '#'.
var dblList = new ObjectPropertyList(null);
dblList.Add(1062028, $"{42.0:#}");
Assert.Equal((1062028, 42.0.ToString("#")), Decode(dblList)[0]); // "42"
}
[Fact]
public void Add_TruncatesArgumentOverMaxLength()
{