Utf8StringInterpolation icon indicating copy to clipboard operation
Utf8StringInterpolation copied to clipboard

Utf8StringWriter<T>.AppendLine shadows the eponymous extension method.

Open markk-df opened this issue 2 months ago • 0 comments

The Utf8StringWriter<T> type has:

  • Instance method: void AppendLine(string s)
  • Extension method: void AppendLine(ref Utf8StringWriter<T>, [InterpolatedStringHandler] ref Utf8StringWriter<T>)

Due to C# overload resolution rules, calling writer.AppendLine($"...") always resolves to the instance method, causing the interpolated string to be evaluated via string.Format (allocations + boxing) instead of using the zero-allocation handler.

This defeats the primary purpose of the library and creates a silent performance trap.

markk-df avatar Oct 22 '25 07:10 markk-df