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
We add support for interpolated string handlers to receive a new piece of information, the name of the method they are an argument to, in order to solve a pain point in the creation of handler types and make them more useful in logging scenarios.
publicvoidLogWarn(thisILoggerlogger,[InterpolatedStringHandlerArgument("Method Name",nameof(logger))]LogInterpolatedStringHandlermessage);-------// Original codevarsomeOperation= RunOperation();ILogger logger =CreateLogger(LogLevel.Error, ...);logger.LogWarn($"Operation was null: {operation is null}");// Approximate translated code:varsomeOperation=RunOperation();ILoggerlogger=CreateLogger(LogLevel.Error, ...);varloggingInterpolatedStringHandler=newLoggingInterpolatedStringHandler(20,1,"LogWarn",logger,outboolcontinueBuilding);if(continueBuilding){loggingInterpolatedStringHandler.AppendLiteral("Operation was null: ");loggingInterpolatedStringHandler.AppendFormatted(operationisnull);}LoggingExtensions.LogWarn(logger,loggingInterpolatedStringHandler);
Interpolated string handler method names
Summary
We add support for interpolated string handlers to receive a new piece of information, the name of the method they are an argument to, in order to solve a pain point in the creation of handler types and make them more useful in logging scenarios.
Design meetings
The text was updated successfully, but these errors were encountered: