Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Tips Showing #31

Open
DavidRogersDev opened this issue Mar 28, 2018 · 6 comments
Open

No Tips Showing #31

DavidRogersDev opened this issue Mar 28, 2018 · 6 comments

Comments

@DavidRogersDev
Copy link

Hi. I just created a console project to test out this analyzer. I cannot seeing anything in the way of tooltips etc.

I have used Serilog 2.5.0 and SerilogAnalyzer 0.13.0.0, both .net 4.6.2 in a full framework (not .NET Core) project.

Is there a dependency I need to install which I am missing?

@Suchiman
Copy link
Owner

Suchiman commented Mar 28, 2018

Assuming you've installed everything correctly, do you have a code sample where you'd expect something to happen and what would you expect to see in particular?
How did you install it? Visual Studio Extension or the nuget analyzer?

@markashton
Copy link

@DavidRogersDev They will only show if you are using the static Log logger, not the ILogger from Microsoft.Extensions.Logging. This threw me for a while until I realised why I wasn't seeing any tooltips. It does mean the analyzer hasn't really helped us, as we use the ILogger in nearly all logging situations.

@Suchiman
Copy link
Owner

Suchiman commented Aug 6, 2018

@markashton the analyzer analyzes everything by the rules of serilog that is decorated with [MessageTemplateFormatMethod("messageTemplate")] which also includes Serilogs ILogger, just not Microsofts ILogger

@markashton
Copy link

markashton commented Aug 6, 2018

I'm not sure I completely follow - there is an open issue asking for support for Microsoft.Extensions.Logging.ILogger (#15) and if I purposefully write a 'bad' log line such as this:
_logger.LogInformation("No result found for query, SearchTerm{searchTerm} Page:{page} PerPage:{perPage}", searchTerm);
... then the analyzer will not highlight any problems. If I change that line to use the static Serilog logger like so:
Log.Information("No result found for query, SearchTerm{searchTerm} Page:{page} PerPage:{perPage}", searchTerm);
... then the analyzer correctly complains about the casing of my properties, and the missing arguments.

In this case my _logger is an Microsoft.Extensions.Logging.ILogger<SearchController>

@Suchiman
Copy link
Owner

Suchiman commented Aug 6, 2018

@markashton if you use

Serilog.ILogger _logger = Log.ForContext<T>();
_logger.Information("No result found for query, SearchTerm{searchTerm} Page:{page} PerPage:{perPage}", searchTerm);

then it also works.
Authors of logging Frameworks are not very creative 😉 so the interface is usually ILog or ILogger, both, Microsoft and Serilog, have an ILogger interface, SerilogAnalyzer also works on Serilog.ILogger because it's decorated with [MessageTemplateFormatMethod("messageTemplate")] which is the indicator for the analyzer that this method should be analyzed. SerilogAnalyzer doesn't care about static classes or specific classes, it only cares about methods decorated with that attribute.

@Alexandr-Pletnev
Copy link

Alexandr-Pletnev commented Dec 13, 2022

Have the same issue. Doesn't highlight
image

Why do expressions marked "?" not highlighted?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants