tannergooding,
@tannergooding@dotnet.social avatar

If you've not seen it, C# 10/.NET 6 introduced support for interpolated string handlers which allows string interpolation to be used efficiently with things like loggers: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/interpolated-string-handler

It's definitely worth checking out and seeing if your logger of choice has updated to support it yet.

bitbonk,
@bitbonk@mastodon.social avatar

@tannergooding Is Microsoft.Extensions.Logging using this feature?

tannergooding,
@tannergooding@dotnet.social avatar

@bitbonk Not sure, that's a bit higher up in the stack than I normally work.

@davidfowl or @damianedwards might be better people to ask.

At a glance, it looks like "no", which might be due to it being oriented around an interface and pre-dating the feature.

I do know that Debug.Assert, Debug.WriteIf, Debug.WriteLineIf, span.TryWrite, stringBuilder.Append, stringBuilder.AppendLine, Utf8.TryWrite, and a number of string and other APIs all use the feature.

davidfowl,

@tannergooding @bitbonk @damianedwards it doesn’t but there are reasons beyond the predating of the feature. Preservation of parameter names in the expression, rebuilding the string everytime would make it somewhat less efficient than using a constant message template

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • ngwrru68w68
  • InstantRegret
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • tacticalgear
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • ethstaker
  • JUstTest
  • GTA5RPClips
  • modclub
  • tester
  • Leos
  • osvaldo12
  • cisconetworking
  • everett
  • cubers
  • normalnudes
  • anitta
  • megavids
  • provamag3
  • lostlight
  • All magazines