Skip to content

Serilog003 gives false positive on my custom abstraction #19

@tiesmaster

Description

@tiesmaster

Hi, awesome analyzer, btw. I really like it. Though, I'm getting a false postive on the following line:

                int id = 1;
                _log.Error("The id is {Id}", id);

Where _log is an instance of our own abstraction ILogger (it might not be too valuable, but that's a different discussion), which looks like this:

    public interface ILogger
    {
        [MessageTemplateFormatMethod("messageTemplate")]
        void Debug(string messageTemplate);
        [MessageTemplateFormatMethod("messageTemplate")]
        void Debug(string messageTemplate, params object[] values);
        [MessageTemplateFormatMethod("messageTemplate")]
        void Error(string messageTemplate, params object[] values);
        [MessageTemplateFormatMethod("messageTemplate")]
        void Error(Exception exception, string messageTemplate, params object[] values);
        [MessageTemplateFormatMethod("messageTemplate")]
        void Information(string messageTemplate);
        [MessageTemplateFormatMethod("messageTemplate")]
        void Information(string messageTemplate, params object[] values);
        [MessageTemplateFormatMethod("messageTemplate")]
        void Warning(string messageTemplate, params object[] propertyValues);
        [MessageTemplateFormatMethod("messageTemplate")]
        void Warning(string messageTemplate);
    }

And with that, it will give me:

1>C:\src\duprix\DuPrix.Services\CompetitorPricing\RecommendationService.cs(124,39,124,43): error Serilog003: Error while binding properties: There is no argument that corresponds to the named property 'Id'

If I have time, I'll see if I can reproduce this in a unit test, and sent you a PR, if you're accepting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions