Skip to content

Logging source generation: the WarningLogMethod example reports SYSLIB1013, not SYSLIB0025 #57059

In progress

Description

@jagdish-kumawat

Type of issue

Other (describe below)

Description

Under "Log method anatomy", the article says the WarningLogMethod example (Message = "M1 {Ex} {Ex2}") reports SYSLIB0025:

In the preceding example, the WarningLogMethod reports a DiagnosticSeverity.Warning of SYSLIB0025.

The warning it reports is SYSLIB1013. SYSLIB0025 is "SuppressIldasmAttribute is obsolete", an unrelated obsoletion warning. The message the article quotes below that sentence is SYSLIB1013's.

Repro with .NET SDK 10.0.404 and Microsoft.Extensions.Logging.Abstractions 10.0.15: the article's example in a file-based app, run with dotnet run Program.cs:

#:package Microsoft.Extensions.Logging.Abstractions@10.0.15
using Microsoft.Extensions.Logging;

Console.WriteLine("Built.");

static partial class Log
{
    // The example from the "Compile-time logging source generation" article.
    // This causes a warning
    [LoggerMessage(
        EventId = 0, Level = LogLevel.Debug, Message = "M1 {Ex} {Ex2}")]
    public static partial void WarningLogMethod(
        ILogger logger,
        Exception ex,
        Exception ex2);
}

Output:

Program.cs(14,19): warning SYSLIB1013: Don't include a template for ex in the logging message since it is implicitly taken care of (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1013)
Built.

The sentence on main: [source-generation.md line 97](https://github.com/dotnet/docs/blob/main febe6ad/docs/core/extensions/logging/source-generation.md#L97). Changing SYSLIB0025 to SYSLIB1013 there (and linking the SYSLIB1013 page) would fix it.

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/logging/source-generation

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/logging/source-generation.md

Document Version Independent Id

443c0b98-55c6-5519-7da5-380f45076c7b

Platform Id

f655ece6-62d1-5404-329a-3c3cafa94103

Article author

@gewarren

Metadata

  • ID: 697f6282-9c7f-2435-87e5-0a889a6dfcb9
  • PlatformId: f655ece6-62d1-5404-329a-3c3cafa94103
  • Service: dotnet-fundamentals

Related Issues

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions