-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Description
# 1
[InterpolatedStringHandler]
public ref struct LogInterpolatedStringHandler
{
…
// Add the receiver argument:
…I guess // Add the receiver argument: is forgotten since Improved Interpolated Strings discusses declaratively receiver term.
# 2
public LogInterpolatedStringHandler(int literalLength, int formattedCount, LogLevel level, Logger logger, out bool isEnabled)
{
enabled = logger.EnabledLevel >= level;
Console.WriteLine($"\tliteral length: {literalLength}, formattedCount: {formattedCount}");
if (enabled)
{
builder = new StringBuilder(literalLength);
}
isEnabled = enabled;
}In fact there are 2 failures:
loggerandlevelparameters are switched so declaration[InterpolatedStringHandlerArgument("", "level")] LogInterpolatedStringHandler builderdoes not work with it.LogInterpolatedStringHandleris declared asstructsobuildermust be definitely assigned when .ctor returns. So either it must be changed toclassor used something likebuilder = enabled ? new () : null;.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 99599c47-14ba-6e35-9b63-daa928f764bb
- Version Independent ID: e80a06d-bfbc-29f1-1cca-248460e523d3
- Content: Explore string interpolation handlers
- Content Source: docs/csharp/whats-new/tutorials/interpolated-string-handler.md
- Product: dotnet-csharp
- Technology: csharp-whats-new
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn