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
When using formatting specifiers in log message templates like {@Data} or {$Data}, the logging source generator logs warnings and errors but should compile fine.
Reproduction Steps
using Microsoft.Extensions.Logging;publicstaticpartialclassExtensions{publicstaticvoidLogPerson(thisILoggerlogger,Personperson)=> logger.LogInformation("The person is {@Person}", person);[LoggerMessage(Level = LogLevel.Information, Message ="The person is {@Person}")]publicstaticpartialvoidOtherLogPerson(thisILoggerlogger,Personperson);}publicrecordPerson(stringFirstName,stringLastName){publicoverridestringToString()=>$"Person({FirstName}{LastName})";}
Depending on the formatter used (NLog/Serilog/inbox console) there should be a difference when using {@Person} vs {Person} (in some cases {$Person})
Expected behavior
The code should compile without warnings or errors.
Actual behavior
SYSLIB1015 and SYSLIB1014 diagnostics and CS0119 error:
C:\demos\LoggingGeneratorFormatErrorExample\Class1.cs(9,75): warning SYSLIB1015: Argument 'person' is not referenced from the logging message [C:\demos\LoggingGeneratorFormatErrorExample\LoggingGeneratorErrorExample.csproj]
C:\demos\LoggingGeneratorFormatErrorExample\Class1.cs(8,6): error SYSLIB1014: Template '@Person' is not provided as argument to the logging method [C:\demos\LoggingGeneratorFormatErrorExample\LoggingGeneratorErrorExample.csproj]
C:\demos\LoggingGeneratorFormatErrorExample\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(20,41): error CS0119: 'Person' is a type, which is not valid in the given context [C:\demos\LoggingGeneratorFormatErrorExample\LoggingGeneratorErrorExample.csproj]
Configuration
.NET 6 class library with 6.0.0 Microsoft.Extensions.Logging nuget pacakge
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.
Issue Details
Description
When using formatting specifiers in log message templates like {@Data} or {$Data}, the logging source generator logs warnings and errors but should compile fine.
Reproduction Steps
using Microsoft.Extensions.Logging;publicstaticpartialclassExtensions{publicstaticvoidLogPerson(thisILoggerlogger,Personperson)=> logger.LogInformation("The person is {@Person}", person);[LoggerMessage(Level = LogLevel.Information, Message ="The person is {@Person}")]publicstaticpartialvoidOtherLogPerson(thisILoggerlogger,Personperson);}publicrecordPerson(stringFirstName,stringLastName){publicoverridestringToString()=>$"Person({FirstName}{LastName})";}
Depending on the formatter used (NLog/Serilog/inbox console) there should be a difference when using {@Person} vs {Person} (in some cases {$Person})
Expected behavior
The code should compile without warnings or errors.
Actual behavior
SYSLIB1015 and SYSLIB1014 diagnostics:
C:\demos\LoggingGeneratorFormatErrorExample\Class1.cs(9,75): warning SYSLIB1015: Argument 'person' is not referenced from the logging message [C:\demos\LoggingGeneratorFormatErrorExample\LoggingGeneratorErrorExample.csproj]
C:\demos\LoggingGeneratorFormatErrorExample\Class1.cs(8,6): error SYSLIB1014: Template '@Person' is not provided as argument to the logging method [C:\demos\LoggingGeneratorFormatErrorExample\LoggingGeneratorErrorExample.csproj]
C:\demos\LoggingGeneratorFormatErrorExample\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(20,41): error CS0119: 'Person' is a type, which is not valid in the given context [C:\demos\LoggingGeneratorFormatErrorExample\LoggingGeneratorErrorExample.csproj]
Description
When using formatting specifiers in log message templates like
{@Data}
or{$Data}
, the logging source generator logs warnings and errors but should compile fine.Reproduction Steps
Depending on the formatter used (NLog/Serilog/inbox console) there should be a difference when using
{@Person}
vs{Person}
(in some cases{$Person}
)Expected behavior
The code should compile without warnings or errors.
Actual behavior
SYSLIB1015 and SYSLIB1014 diagnostics and CS0119 error:
Configuration
.NET 6 class library with 6.0.0
Microsoft.Extensions.Logging
nuget pacakgeThe text was updated successfully, but these errors were encountered: