You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Avoid building StringBuilder in DefaultInterpolatedStringHandler #105775
When passing a builder to an interpolation $".. {stringBuilder} .." the builder is first converted to an string, duplicating the total allocation needed to evaluate this expression. Could DefaultInterpolatedStringHandler specially handle builders so that this doesn't happen?
changed the title [-]Avoid building `StringBuilder` in `DefaultInterpolatedStringHandler.AppenFormatted<T>(T)`[/-][+]Avoid building `StringBuilder` in `DefaultInterpolatedStringHandler`[/+]on Jul 31, 2024
I'm not excited at the idea of special-casing StringBuilder in DefaultInterpolatedStringHandler. If it's a problem to be solved, I'd rather it be solved by having StringBuilder implement ISpanFormattable.
Reacted by Alireza Habibi, Cole Tobin, Huo Yaoyuan, karakasa, Linus Schwartz Hamlin, Juliano Leal Goncalves, D3-LucaPiombino and Paulus Pärssinen
Activity
[-]Avoid building `StringBuilder` in `DefaultInterpolatedStringHandler.AppenFormatted<T>(T)`[/-][+]Avoid building `StringBuilder` in `DefaultInterpolatedStringHandler`[/+]stephentoub commentedon Jul 31, 2024
I'm not excited at the idea of special-casing StringBuilder in DefaultInterpolatedStringHandler. If it's a problem to be solved, I'd rather it be solved by having StringBuilder implement ISpanFormattable.
dotnet-policy-service commentedon Aug 1, 2024
Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.
karakasa commentedon Aug 2, 2024
So is implementing
ISpanFormattableonStringBuilderan api-suggestion?stephentoub commentedon Aug 2, 2024
yup
karakasa commentedon Aug 2, 2024
OK. Let me propose an issue.
jeffhandley commentedon Aug 6, 2024
Closed with the creation of #105870