-
-
Save maryamariyan/a1ab553bedb26b9886fbc2740ee9e954 to your computer and use it in GitHub Desktop.
generator error messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// - [ ] Revisit severity of diagnostics with latest changes and add for the missing 4, check if severity for all makes sense, check if generic enough to fit in libraries. | |
// error SYSLIB0000: Logging method names cannot start with _ | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
static partial void __M1(ILogger logger); | |
// error SYSLIB0001: Don't include a template for l1 in the logging message since it is implicitly taken care of | |
// DiagnosticSeverity.Warning, | |
[LoggerMessage(0, "M1 {l1} {l2}")] | |
static partial void M1(ILogger logger, LogLevel l1, LogLevel l2); | |
// error SYSLIB0002: Logging method parameter names cannot start with _ | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "M1 {__foo}")] | |
static partial void M1(ILogger logger, string __foo); | |
// error SYSLIB0003: Logging class cannot be in nested types | |
// DiagnosticSeverity.Error, | |
public partial class Nested | |
{ | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
static partial void M1(ILogger logger); | |
} | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
static partial void M1(ILogger logger); | |
// error SYSLIB0004: Could not find a required type definition | |
// DiagnosticSeverity.Error, | |
// Sample | |
// error SYSLIB0005: Multiple logging methods are using event id 0 | |
// DiagnosticSeverity.Warning, | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
static partial void M2(ILogger logger); | |
// error SYSLIB0006: Logging methods must return void | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
public static partial int M1(ILogger logger); | |
public static partial int M1(ILogger logger) { return 0; } | |
// error SYSLIB0007: One of the arguments to a logging method must implement the Microsoft.Extensions.Logging.ILogger interface | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "M1 {p1}")] | |
static partial void M1(int p1); | |
// error SYSLIB0008: Logging methods must be static | |
// DiagnosticSeverity.Warning, | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
partial void M1(ILogger logger); | |
// error SYSLIB0009: Logging methods must be partial | |
// DiagnosticSeverity.Error, | |
// error SYSLIB0016: Logging methods cannot have a body | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
static void M1(ILogger logger) { } | |
// error SYSLIB0010: Logging methods cannot be generic | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
static partial void M1<T>(ILogger logger); | |
// warning SYSLIB0011: Remove redundant qualifier (Info:, Warning:, Error:, etc) from the logging message since it is implicit in the specified log level. | |
// DiagnosticSeverity.Warning, | |
[LoggerMessage(0, LogLevel.Information, "INFO: this is an informative message")] | |
static partial void M1(ILogger logger); | |
// warning SYSLIB0012: No need to supply a DateTime value as argument since the logging infrastructure inserts one implicitly | |
// DiagnosticSeverity.Warning, | |
[LoggerMessage(0, LogLevel.Debug, "M1 {timeStamp}")] | |
static partial void M1(ILogger logger, System.DateTime timeStamp); | |
// warning SYSLIB0013: Don't include a template for ex in the logging message since it is implicitly taken care | |
// DiagnosticSeverity.Warning, | |
[LoggerMessage(0, LogLevel.Debug, "M1 {ex} {ex2}")] | |
static partial void M1(ILogger logger, System.Exception ex, System.Exception ex2); | |
// As a general rule, the first instance of ILogger, LogLevel, and Exception are treated specially in the log method signature. Subsequent instances are treated like normal args | |
// error SYSLIB0014: Template foo is not provided as argument to the logging method | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "{foo}")] | |
static partial void M1(ILogger logger); | |
// warning SYSLIB0015: Argument foo is not referenced from the logging message | |
// DiagnosticSeverity.Warning, | |
[LoggerMessage(0, LogLevel.Debug, "This is a message without foo")] | |
static partial void M1(ILogger logger, string foo); | |
// error SYSLIB0016: Logging methods cannot have a body | |
// DiagnosticSeverity.Error, | |
static partial void M1(ILogger logger); | |
[LoggerMessage(0, LogLevel.Debug, "M1")] | |
static partial void M1(ILogger logger) { } | |
// error SYSLIB0017: A LogLevel value must be supplied in the LoggerMessage attribute or as a parameter to the logging method | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, "M1")] | |
static partial void M1(ILogger logger); | |
// error SYSLIB0018: Don't include a template for logger in the logging message since it is implicitly taken care of | |
// DiagnosticSeverity.Error, | |
[LoggerMessage(0, LogLevel.Debug, "M1 {logger}")] | |
static partial void M1(ILogger logger); | |
// error SYSLIB0019: Couldn't find a field of type Microsoft.Extensions.Logging.ILogger in class {0} | |
// DiagnosticSeverity.Error, | |
public partial class LoggingSampleWithNoILoggerFieldsError | |
{ | |
public LoggingSampleWithNoILoggerFieldsError() { } | |
[LoggerMessage(10, LogLevel.Warning, "Welcome to {city} {province}!")] | |
public partial void LogMethodSupportsPascalCasingOfNames(string city, string province); | |
public void TestLogging() | |
{ | |
LogMethodSupportsPascalCasingOfNames("Vancouver", "BC"); | |
} | |
} | |
// error SYSLIB0020: Found multiple fields of type Microsoft.Extensions.Logging.ILogger in class {0} | |
// DiagnosticSeverity.Error, | |
public partial class LoggingSampleWithMultipleILoggerFieldsError | |
{ | |
private readonly ILogger _loggerX; | |
private readonly ILogger _loggerY; | |
public LoggingSampleWithMultipleILoggerFieldsError(ILogger logger1, ILogger logger2) | |
{ | |
_loggerX = logger1; | |
_loggerY = logger2; | |
} | |
[LoggerMessage(10, LogLevel.Warning, "Welcome to {city} {province}!")] | |
public partial void LogMethodSupportsPascalCasingOfNames(string city, string province); | |
public void TestLogging() | |
{ | |
LogMethodSupportsPascalCasingOfNames("Vancouver", "BC"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment