-
Notifications
You must be signed in to change notification settings - Fork 29
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
How to trigger refactoring? #41
Comments
Can you post a snippet on which it does not work? |
Holy smokes, that was a fast response! var logger = new LoggerConfiguration()
.Enrich.WithThreadId()
.Enrich.WithEnvironmentUserName()
.WriteTo.Console(
outputTemplate: "{Timestamp:s} {Level:u12} [{ThreadId}] [{SourceContext}] [{EnvironmentUserName}]{NewLine}{Message}{NewLine}---------------{NewLine}",
theme: AnsiConsoleTheme.Code)
.CreateLogger(); |
It does work for me on this snippet, you can place the cursor anywhere between It's running into a limitation though on
"Serilog": {
"Using": ["Serilog.Enrichers.Environment", "Serilog.Enrichers.Thread", "Serilog.Sinks.Console"],
"WriteTo": [
{ "Name": "Console", "Args": { "outputTemplate": "{Timestamp:s} {Level:u12} [{ThreadId}] [{SourceContext}] [{EnvironmentUserName}]{NewLine}{Message}{NewLine}---------------{NewLine}", "theme": "?" } }
],
"Enrich": ["WithEnvironmentUserName", "WithThreadId"]
} <add key="serilog:enrich:WithEnvironmentUserName" />
<add key="serilog:enrich:WithThreadId" />
<add key="serilog:write-to:Console.outputTemplate" value="{Timestamp:s} {Level:u12} [{ThreadId}] [{SourceContext}] [{EnvironmentUserName}]{NewLine}{Message}{NewLine}---------------{NewLine}" />
<add key="serilog:write-to:Console.theme" value="?" />
<add key="serilog:using:Environment" value="Serilog.Enrichers.Environment" />
<add key="serilog:using:Thread" value="Serilog.Enrichers.Thread" />
<add key="serilog:using:Console" value="Serilog.Sinks.Console" /> |
Here's the details on my VS Installation. It's the most up to date version of 2017. Microsoft Visual Studio Enterprise 2017 |
Are you using the nuget version? It seems that while Analyzers and CodeFixes work, CodeRefactorings do not. If you're using the nuget version, you should be able to workaround the issue by installing from here https://marketplace.visualstudio.com/items?itemName=Suchiman.SerilogAnalyzer |
Oh yeah, I am using the Nuget version. I just forked the project and will try debugging the issue and try to provide some further info. Although, that will just use the VSIX extension and maybe it won't be a problem... At any rate, I've got a bit of recent experience working with developing analyzers. I'll see what I can see. |
When I run it through the debugger it shows me the refactoring which appears to include an error. Not sure if that's an issue when running it from nuget? Here's the output: /*
Errors:
C:\Code\----redacted----\Configuration\SerilogConfig.cs: (18,27)-(18,48): `AnsiConsoleTheme.Code` -> Can't statically determine value of expression
"Serilog": {
"Using": ["Serilog.Enrichers.Environment", "Serilog.Enrichers.Thread", "Serilog.Sinks.Console"],
"WriteTo": [
{ "Name": "Console", "Args": { "outputTemplate": "{Timestamp:s} {Level:u12} [{ThreadId}] [{SourceContext}] [{EnvironmentUserName}]{NewLine}{Message}{NewLine}---------------{NewLine}", "theme": "?" } }
],
"Enrich": ["WithEnvironmentUserName", "WithThreadId"]
}
*/ |
@mikesigs that is nothing to worry about (in terms of analyzing), that just means that |
In my own analyzer I added some custom logging (writing to a file basically) to help diagnose some issues. Also, it looks like you can put the themes in configuration like this: Totally unrelated, but perhaps a feature suggestion ;) |
Yes i need to catch up with improvements to the config system of serilog 😉 |
It's possible I am not nuget packing this thing correctly. And I've never worked with PCL's before. But when I create a nuget package locally and try to reference it, I get a bunch of warnings stating that Microsoft.CodeAnalysis... 1.0.0 was restored using .NETFramework 4.6.1 instead of .NETCoreApp. But when I use your version from Nuget, it doesn't display those warnings. But perhaps this is a .NET Core compatibility thing underneath somehow?? If that's the case, it might require updating to .NET Standard. Let me know if you'd like some help with that. For now, I am gonna just move forward without the refactoring part. Or... if I need it, I'll install the VSIX. |
So actually this is by design from roslyn, code refactorings only get loaded from VSIX packages, see explanation here dotnet/roslyn#32705 (comment) |
First of all, I gotta say how amazing this analyzer is! Thank you for building it!
I cannot figure out how to trigger the refactoring of the LoggerConfiguration though. Judging by the gif in the README, it looks like you must just put the cursor before the parens on
CreateLogger()
and hitCtrl+.
, but that doesn't work for me. I have tried all various ways to trigger and it just ain't workin.What might I be missing?
The text was updated successfully, but these errors were encountered: