- Added
TryFormatEnum/TryFormatEnumUnderlyingin_XShandler D,d: formats enum as decimal numeric value viaUnsafe.As<T, underlying>— zero boxingX,x: formats enum as hex with zero-padded digits matching underlying type size (e.g. int →X8)G,F, and other specifiers: fallback toIFormattable.ToString(boxes)- Previously all enum format specifiers were ignored (ZString
EnumUtil<T>limitation)
TMP_Text.SetTextX($"...")sets interpolated string to TextMeshPro with zero string allocation- Passes internal
char[]buffer directly viaSetCharArray(bypassesToString()) - Benchmark: GC 5 (TMP internal only) vs GC 12 (
tmp.text = $"...")
- Changed retry buffer from
written > buf.Length ? written : buf.Length * 2tobuf.Length * 2 writtenis unreliable on TryFormat failure (may be 0 or partial), so always double the buffer
- FormatException message now includes
Type,alignment,formatfor easier debugging
- Removed
AppendFormattedViaComposite, replaced withAppendFormatInternal - Before: built composite format string (
"{0,alignment:format}") on the stack per call, then re-parsed via_sb.AppendFormat - After: calls
FormatterCache<T>.TryFormatDelegatedirectly and handles alignment padding inline - Eliminates composite string construction and re-parsing overhead
- Changed null check from
value == nulltodefault(T) == null && value == null - Prevents unnecessary boxing for value types (null branch entered only for reference types / Nullable)
StringBuilder_FourArgs: changed from reusing StringBuilder to creating a new instance per iteration (fair comparison)StringBuilder128_FourArgs: added benchmark that creates a new StringBuilder with initial capacity 128 per iterationStringBuilderShare_FourArgs: separated the existing shared-StringBuilder approach into its own benchmark
Alignment and format specifiers are now properly supported.
- Fixed: Alignment and format parameters were previously ignored
- Example:
XString.Format($"Score: {score,10:F2}")aligns to 10 characters with 2 decimal places
Format overloads extended from T1T4 to T1T16.
- Example:
XString.Format("{0} {1} ... {15}", arg1, arg2, ..., arg16)
Expanded from 34 to 93 (+174%)
Added tests:
- 4 concurrency tests (multithreading safety)
- 11 edge case tests (boundary conditions, large strings)
- 33 functional tests (various scenarios)
- First release