Skip to content

Compile-time logging source generation example triggers analyzer error "partial method must have an implementation part because it has accessibility modifiers" #27471

Closed
@wjrogers

Description

@wjrogers

When I write a class like the one in the example on this page,

public static partial class Log
{
    [LoggerMessage(
        EventId = 0,
        Level = LogLevel.Critical,
        Message = "Could not open socket to `{hostName}`")]
    public static partial void CouldNotOpenSocket(
        ILogger logger, string hostName);
}

the IDE flags it with an error:

Partial method 'void CouldNotOpenSocket(ILogger, string)' must have an implementation part because it has accessibility modifiers.

However, the code compiles and executes successfully. Will you please add some guidance to this page about this error, especially if there is a way to silence it?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 68965

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions