Description
Problem
The FormattableString overloads for logging added in #4698 (Information(FormattableString) etc. on LogExtensions and LoggingAliases) are only used when the argument is explicitly typed as FormattableString. An inline interpolated string such as
Information($"Hello {name}");binds to Information(string value), because C# treats the conversion to string as the better one. The string is flattened before it reaches the log, so the arguments aren't highlighted in the console output.
Findings
[OverloadResolutionPriority(1)](C# 13, available since we target net10.0+) on theFormattableStringoverloads would make interpolated strings prefer them. Plain strings andInformation("{0}", value)would be unaffected, since a plain string isn't an interpolated string.- That attribute has no effect in
.cakescripts unlessMethodAliasGeneratoralso emits it on the generated alias proxy methods. - Routing interpolated strings through
FormatParser/PropertyTokenwould expose two existing parser bugs:- Alignment, e.g.
$"{x,10}", throwsFormatException. - Formats containing
:, e.g.$"{now:HH:mm:ss}", lose their colons and render asHHmmss.
- Alignment, e.g.
Expected
Information($"Hello {name}") (and Error/Warning/Verbose/Debug, with or without a Verbosity argument) uses the FormattableString overload, in both C# and Cake scripts. Alignment and : formats render the same as string.Format.
Notes
This is a source-level behaviour change for custom ICakeLog implementations and mocks: for an inline $"...", they'd receive "Hello {0}", [name] instead of "{0}", ["Hello name"].
Activity
Merge pull request #5156 from devlead/feature/gh-5155
(cake-buildGH-5155) Prefer FormattableString log overloads for interp…
github-actions commentedon Nov 10, 2026
🎉 This issue has been resolved in version v7.0.0 🎉
The release is available on:
Your GitReleaseManager bot 📦🚀
Bump cake.tool from 6.3.0 to 7.0.0 (#40639)