diff --git a/Projects/Server/Serial.cs b/Projects/Server/Serial.cs index fcb43a07b..1ad089243 100644 --- a/Projects/Server/Serial.cs +++ b/Projects/Server/Serial.cs @@ -118,36 +118,15 @@ public readonly struct Serial : IComparable, IComparable, IEquatab public static Serial operator --(Serial l) => (Serial)(l.Value - 1); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override string ToString() => $"0x{Value:X8}"; + public override string ToString() => $"{this}"; public string ToString(string format, IFormatProvider formatProvider) => ToString(); public bool TryFormat( Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider provider - ) - { - if (format != null) - { - return Value.TryFormat(destination, out charsWritten, format, provider); - } - - if (destination.Length < 10) - { - charsWritten = 0; - return false; - } - - destination[0] = '0'; - destination[1] = 'x'; - - var result = Value.TryFormat(destination[2..], out charsWritten, "X8", provider); - if (result) - { - charsWritten += 2; - } - - return result; - } + ) => format != null + ? Value.TryFormat(destination, out charsWritten, format, provider) + : destination.TryWrite(provider, $"0x{Value:X8}", out charsWritten); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator uint(Serial a) => a.Value;