Skip to content

Support C# 6 interpolated strings through IFormattable and/or FormattableString #825

Description

@stylpe

The new string interpolation syntax in C# 6 has a drawback when used with NLog: It performs the interpolation regardless of which log levels are enabled (since it has to be passed as a string to NLog; I haven't found any evidence to the contrary at least). It should be possible to avoid this if we can pass the interpolated string as IFormattable or FormattableString.

https://msdn.microsoft.com/en-us/library/dn961160.aspx describes how interpolated strings can be implicitly cast to IFormattable and FormattableString, which gave me the idea.

I haven't had a chance to dive deep into the details about performance, but I found this interesting discussion: dotnet/roslyn#518

I leave it to you to judge if it's a good idea, but I couldn't find any mention of IFormattable or FormattableString here, and felt there should at least be an issue discussing it :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions