Open mejobloggs-cw opened 9 months ago
I released a new version of the extension today that I hope will address these problems, or at least make them easier to track down.
The latest (1.5.2) version has a new option "Use CSharpier Server", could you try the new version with that on to see if it resolves the issue?
You'll get a windows firewall popup about dotnet-csharpier needing internet access, which it doesn't. The extension communicates with the cli over http with this new version. I resolved the firewall warning in that in #1184 but it hasn't been released yet.
It's still happening, but there's a lot more logs now.
This is without the new "Use CSharpier Server" option enabled
[Info - 20/02/2024 9:41:06 am] Starting
[Debug - 20/02/2024 9:41:39 am] Ensure there is a csharpier process for E:\Blah\Blah\Blah
[Debug - 20/02/2024 9:41:39 am] Looking for E:\Blah\Blah\Blah\.config/dotnet-tools.json
[Debug - 20/02/2024 9:41:39 am] Looking for E:\Blah\Blah\.config/dotnet-tools.json
[Debug - 20/02/2024 9:41:39 am] Looking for E:\Blah\.config/dotnet-tools.json
[Debug - 20/02/2024 9:41:39 am] Looking for E:\.config/dotnet-tools.json
[Debug - 20/02/2024 9:41:39 am] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
[Debug - 20/02/2024 9:41:41 am] dotnet csharpier --version output: 0.27.3
[Debug - 20/02/2024 9:41:41 am] Using 0.27.3 as the version number.
[Debug - 20/02/2024 9:41:41 am] dotnet csharpier --version output: 0.27.3
[Debug - 20/02/2024 9:41:41 am] Using 0.27.3 as the version number.
[Debug - 20/02/2024 9:41:41 am] CSharpier at C:\Users\MyUserName\AppData\Local\CSharpier\0.27.3 already exists
[Debug - 20/02/2024 9:41:41 am] Adding new version 0.27.3 process for E:\Blah\Blah\Blah
[Debug - 20/02/2024 9:41:41 am] Warm CSharpier with initial format
[Warn - 20/02/2024 9:41:44 am] CSharpier process appears to be hung, restarting it.
[Warn - 20/02/2024 9:41:47 am] CSharpier process appears to be hung, restarting it.
[Debug - 20/02/2024 9:41:47 am] Ensure there is a csharpier process for E:\Blah\Blah\Blah
[Debug - 20/02/2024 9:41:47 am] Ensure there is a csharpier process for E:\Blah\Blah\Blah
I will try the Server option now....
Here is the logs with Server option also. I have no Visual Studio warning using Server option:
[Info - 20/02/2024 9:51:27 am] Starting
[Debug - 20/02/2024 9:51:27 am] Ensure there is a csharpier process for E:\Blah\Blah\Blah
[Debug - 20/02/2024 9:51:27 am] Looking for E:\Blah\Blah\Blah\.config/dotnet-tools.json
[Debug - 20/02/2024 9:51:27 am] Looking for E:\Blah\Blah\.config/dotnet-tools.json
[Debug - 20/02/2024 9:51:27 am] Looking for E:\Blah\.config/dotnet-tools.json
[Debug - 20/02/2024 9:51:27 am] Looking for E:\.config/dotnet-tools.json
[Debug - 20/02/2024 9:51:27 am] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
[Debug - 20/02/2024 9:51:28 am] dotnet csharpier --version output: 0.27.3
[Debug - 20/02/2024 9:51:28 am] Using 0.27.3 as the version number.
[Debug - 20/02/2024 9:51:28 am] dotnet csharpier --version output: 0.27.3
[Debug - 20/02/2024 9:51:28 am] Using 0.27.3 as the version number.
[Debug - 20/02/2024 9:51:28 am] CSharpier at C:\Users\MyUserName\AppData\Local\CSharpier\0.27.3 already exists
[Debug - 20/02/2024 9:51:28 am] Adding new version 0.27.3 process for E:\Blah\Blah\Blah
[Debug - 20/02/2024 9:51:28 am] Connecting via port 49154
[Debug - 20/02/2024 9:51:28 am] Warm CSharpier with initial format
[Debug - 20/02/2024 9:51:38 am] Ensure there is a csharpier process for E:\Blah\Blah\Blah
I just got over a full minute hang on reformat using the Server option. Here's the log
[Debug - 20/02/2024 2:13:43 pm] Ensure there is a csharpier process for E:\Blah\Blah
[Debug - 20/02/2024 2:14:43 pm] OnBeforeSave
[Debug - 20/02/2024 2:14:43 pm] No RunOnSave
[Debug - 20/02/2024 2:14:54 pm] OnBeforeSave
[Debug - 20/02/2024 2:14:54 pm] No RunOnSave
[Debug - 20/02/2024 2:15:53 pm] OnBeforeSave
[Debug - 20/02/2024 2:15:53 pm] No RunOnSave
[Info - 20/02/2024 2:15:57 pm] Formatting started for E:\Blah\Startup.cs.
[Warn - 20/02/2024 2:17:37 pm] Failed posting to the csharpier server. System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at CSharpierProcessServer.FormatFile(String content, String filePath)
[Info - 20/02/2024 2:17:37 pm] Formatted in 100021ms
[Debug - 20/02/2024 2:17:37 pm] Skipping write because result is empty
[Debug - 20/02/2024 2:17:37 pm] OnBeforeSave
[Debug - 20/02/2024 2:17:37 pm] No RunOnSave
[Debug - 20/02/2024 2:17:43 pm] Ensure there is a csharpier process for E:\Blah\Blah
[Debug - 20/02/2024 2:17:45 pm] OnBeforeSave
[Debug - 20/02/2024 2:17:45 pm] No RunOnSave
Ok yeah, still getting the "Visual Studio stopped responding" message sometimes while using the Server option.
"Visual Studio stopped responding for 7 seconds. Disabling the extension CSharpier 1.5.2 might help. Disable this extension Manage performance Don't report this extension again "
[Info - 21/02/2024 10:43:47 am] Starting
[Error - 21/02/2024 10:43:59 am] System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at EnvDTE.Documents.Item(Object index)
at CSharpier.VisualStudio.ReformatWithCSharpierOnSave.FindDocument(UInt32 docCookie)
[Debug - 21/02/2024 10:44:00 am] Ensure there is a csharpier process for E:\Blah\Blah\Blah
[Debug - 21/02/2024 10:44:00 am] Looking for E:\Blah\Blah\Blah\.config/dotnet-tools.json
[Debug - 21/02/2024 10:44:00 am] Looking for E:\Blah\Blah\.config/dotnet-tools.json
[Debug - 21/02/2024 10:44:00 am] Looking for E:\Blah\.config/dotnet-tools.json
[Debug - 21/02/2024 10:44:00 am] Looking for E:\.config/dotnet-tools.json
[Debug - 21/02/2024 10:44:00 am] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
[Debug - 21/02/2024 10:44:02 am] dotnet csharpier --version output: 0.27.3
[Debug - 21/02/2024 10:44:02 am] Using 0.27.3 as the version number.
[Debug - 21/02/2024 10:44:02 am] dotnet csharpier --version output: 0.27.3
[Debug - 21/02/2024 10:44:02 am] Using 0.27.3 as the version number.
[Debug - 21/02/2024 10:44:02 am] CSharpier at C:\Users\MyUserName\AppData\Local\CSharpier\0.27.3 already exists
[Debug - 21/02/2024 10:44:02 am] Adding new version 0.27.3 process for E:\Blah\Blah\Blah
[Debug - 21/02/2024 10:44:04 am] Connecting via port 49160
[Debug - 21/02/2024 10:44:04 am] Warm CSharpier with initial format
I'm thinking there is either something in some of your files that csharpier can't handle. If it is all files in the project, then maybe something in an .editorconfig.
If you create a new file with a basic class in your project, can that be formatted?
Are you able to share the contents of the project?
If you run dotnet csharpier .
in the project, does that work?
I created a new "ASP.NET Core Web API" project with Identity.
Closed VS, opened the project, and got the error again "Visual Studio stopped responding for 9 seconds. Disabling the extension CSharpier 1.5.2"
So it's not the code from my other project or editorconfig. I double checked and no editorconfig is present in the new webapp
[Info - 26/02/2024 11:07:38 am] Starting
[Debug - 26/02/2024 11:07:38 am] Ensure there is a csharpier process for E:\source\WebApplication2\WebApplication2
[Debug - 26/02/2024 11:07:38 am] Looking for E:\source\WebApplication2\WebApplication2\.config/dotnet-tools.json
[Debug - 26/02/2024 11:07:38 am] Looking for E:\source\WebApplication2\.config/dotnet-tools.json
[Debug - 26/02/2024 11:07:38 am] Looking for E:\source\.config/dotnet-tools.json
[Debug - 26/02/2024 11:07:38 am] Looking for E:\.config/dotnet-tools.json
[Debug - 26/02/2024 11:07:38 am] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
[Debug - 26/02/2024 11:07:39 am] dotnet csharpier --version output: 0.27.3
[Debug - 26/02/2024 11:07:39 am] Using 0.27.3 as the version number.
[Debug - 26/02/2024 11:07:39 am] dotnet csharpier --version output: 0.27.3
[Debug - 26/02/2024 11:07:39 am] Using 0.27.3 as the version number.
[Debug - 26/02/2024 11:07:39 am] CSharpier at C:\Users\MyUser\AppData\Local\CSharpier\0.27.3 already exists
[Debug - 26/02/2024 11:07:39 am] Adding new version 0.27.3 process for E:\source\WebApplication2\WebApplication2
[Debug - 26/02/2024 11:07:39 am] Warm CSharpier with initial format
[Warn - 26/02/2024 11:07:42 am] CSharpier process appears to be hung, restarting it.
[Warn - 26/02/2024 11:07:45 am] CSharpier process appears to be hung, restarting it.
[Debug - 26/02/2024 11:07:45 am] Ensure there is a csharpier process for E:\source\WebApplication2\WebApplication2
The logging from the extension side doesn't really give me any indication of what the problem is. I hope to add logging to the csharpier side, but I don't know how soon that will happen.
The only other thing I can think of is for you to debug csharpier.
I'll give it a try but the issue usually doesn't happen when I format a file, it usually happens when I first open Visual Studio.
So I think the method of attaching to a process is too late because I think the issue is in the process start/warmup
Also I notice in Task Manager one dotnet-csharpier.exe
starts for each Visual Studio instance. But when I close Visual Studio, dotnet-csharpier process still exists.
As of right now I have 0 Visual Studio open, but 5 dotnet-csharpier in Task Manager.
Perhaps this is intended behaviour to make next launch faster, not sure, just thought I'd mention it
@belav I get this too every time I open VS,
We're using 0.28.2 in this project.
How should I go about investigating the issue?
Multiple times a day I get this message. "Visual Studio stopped responding for 9 seconds. Disabling the extension CSharpier 1.5.1 might help."
Here is the CSharpier output:
Visual Studio info