-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Milestone
Description
Once Type.IsEnum is an intrinsic (#71685) and the static Enum.TryFormat has been added (#71590), we should be able to update the in-box interpolated string handlers to special-case enums and use TryFormat rather than calling ToString on them, which at a minimum boxes and worst-case allocates a result string. This can either be a long-term solution, or it can be a stop-gap until Enum itself implements ISpanFormattable, which we've said we'll only do if the JIT is updated to avoid boxing when using its methods.
(We can similarly special-case anywhere optimized formatting would be helpful, e.g. maybe in StringBuilder, in ValueStringBuilder, etc.)
PaulusParssinen