Closed JPressmar closed 1 year ago
There is a report of the Rider plugin running into a similar issue - https://github.com/belav/csharpier/issues/926#issuecomment-1798211642
I haven't been able to recreate the issue yet, but my guess is that it may have something to do with the new editorconfig support.
Do you have any editorconfig files in your solution? What about any .csharpierrc files?
It sounds like it freezer while trying to load, is that correct? Are you able to get the output window for csharpier open to see if anything is output there?
Is there a folder at C:\Users\[UserName]\AppData\Local\CSharpier\0.26.0
?
Also can you see if the event viewer has any info? I believe the problem could be this error that I am seeing.
Description: A .NET application failed.
Application: dotnet-csharpier.exe
Path: C:\Users\bela\AppData\Local\CSharpier\0.26.0\dotnet-csharpier.exe
Message: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet\'.
Failed to run as a self-contained app.
- The application was run as a self-contained app because 'C:\Users\bela\AppData\Local\CSharpier\0.26.0\.store\csharpier\0.26.0\csharpier\0.26.0\tools\net8.0\any\dotnet-csharpier.runtimeconfig.json' was not found.
- If this should be a framework-dependent app, add the 'C:\Users\bela\AppData\Local\CSharpier\0.26.0\.store\csharpier\0.26.0\csharpier\0.26.0\tools\net8.0\any\dotnet-csharpier.runtimeconfig.json' file and specify the appropriate framework.
After updating to csharpier 26 (from 25.x) this happens to me as well.
Using neovim with conform Plugin on arch linux.
I got this all morning too, but when changing the editorconfig files externally to better use spelling exclusions in VS17.7.6, I got even harder complete freezes (for minutes, having to kill all VS).
I didn't manage to reduce down to find what extra lines copied from dotnet's project-system .editorconfig causes that.
Especially since the sort usings isn't the same convention as what is configured currently as the project settings (group usings and system first options, both in editorconfig), I think I'll revert to 0.25 for now
I managed to get a log since Visual Studio wasn't completely hung, but not that useful:
Starting
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
CSharpier process appears to be hung, restarting it.
And later:
Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at CSharpier.VisualStudio.ReformatWithCSharpierOnSave.FindDocument(UInt32 docCookie)
Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at CSharpier.VisualStudio.ReformatWithCSharpierOnSave.FindDocument(UInt32 docCookie)
Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at CSharpier.VisualStudio.ReformatWithCSharpierOnSave.FindDocument(UInt32 docCookie)
Same issue for me using Rider. It appears to freeze Rider completely & I have to force quit it. (I'm using the extension)
2023-11-08 13:47:59,717 [ 90270] INFO - #c.j.r.e.RiderEditorPasteHandler - Executing IDEA EditorPaste handler
2023-11-08 13:48:01,005 [ 91558] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1305 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getAccessibleIndexInParent(CAccessibility.java:339)
2023-11-08 13:48:03,006 [ 93559] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 2000 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:651)
2023-11-08 13:48:03,640 [ 94193] WARN - #c.i.c.CSharpierLogger - CSharpier process appears to be hung, restarting it.
2023-11-08 13:48:05,004 [ 95557] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1997 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:651)
2023-11-08 13:48:06,652 [ 97205] WARN - #c.i.c.CSharpierLogger - CSharpier process appears to be hung, restarting it.
2023-11-08 13:48:07,006 [ 97559] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 2001 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:651)
2023-11-08 13:48:09,003 [ 99556] INFO - sun.awt.AWTThreading - InvocationEvent has timed out (awaiting 1997 ms). Originated at java.desktop/sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:651)
2023-11-08 13:48:09,670 [ 100223] WARN - #c.i.c.CSharpierLogger - CSharpier process appears to be hung, restarting it.
Here is the content that I pasted with that lead up to the freeze:
public class TrailDto
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Description { get; set; } = "";
public string Location { get; set; } = "";
public int TimeInMinutes { get; set; }
public int Length { get; set; }
public List<RouteInstruction> Route { get; set; } =
➥new List<RouteInstruction>();
public class RouteInstruction
{
public int Stage { get; set; }
public string Description { get; set; } = "";
}
}
I think I found it. From the task manager, I created a dump, and it generated me a dotnet-csharpier.DMP minidump file. It can be opened in Visual Studio, and it looks like you are at a debugging at a breakpoint. It may not be exactly at the last of the failures (since the process seems to close and retry often), but it was somewhere in the middle.
I was able to see that Ini file parser threw an exception since there was multiple sections with the same name [*]
.
This should trigger it:
https://github.com/dotnet/docfx/blob/baea99a0bd99c0f5a19d1d62b09b0386389dec47/.editorconfig
and here, the [*.{cs,vb}]
section is duplicated, so should trigger it too.
https://github.com/dotnet/project-system/blob/293fd6050cc3d6694ef6f95d4331153fed2f5b2b/.editorconfig
As these comments, it should be valid: https://github.com/editorconfig/editorconfig/issues/97#issuecomment-17372932 https://github.com/editorconfig/editorconfig/issues/97#issuecomment-17373234
I'm not sure if that minidump contains private project information, so I'm not trying to post it publicly, but I kept it.
@echoix thanks for doing the work to track this done! It was a quick fix now that I know what the problem was. I also made sure any other failures with parsing an editorconfig will not cause a hard fail. I'll get a new version of csharpier out shortly with this included.
@echoix thanks for doing the work to track this done! It was a quick fix now that I know what the problem was. I also made sure any other failures with parsing an editorconfig will not cause a hard fail. I'll get a new version of csharpier out shortly with this included.
You're welcome! It would have been even better and easier if the ini parser https://github.com/rickyah/ini-parser had debug symbols embedded and/or sourcelink enabled, but we still got a message.
It's great that you found a way to fix and test some incomplete/invalid editorconfig files, and duplicated sections. I cannot imagine how it cannot fix the hard VS hang.
However, I'm not convinced it will fix the first issue, where VS offers us to disable the extension since it hangs. After finding that the duplicated sections hard hang VS, and removing them, I still often encountered long hangs of at least 12 seconds at each time the banner showed, that I was only notified once per VS restart (per reboot but only for the IDE, not the computer). It was near the beginning of the execution of the IDE, but not at startup, and I could do a little bit of things before it hangs. I don't think it would hang by itself if I didn't do any actions (or saves). It also seemed linked to after I edited the editorconfig in Notepad++, and then really close next to that it would happen (only once). I never got to create a dump while it was hanging (once finished hanging, that's when the yellow banner appears). When I realized it was hanging, I was too slow to go in task manager for the dump. But the dotnet-csharpier process (inside the visual studio 2022 group) was often in the 3-8% of 12 cores CPU usage and the other processes came and go so it continued to move.
Moreover, when looking at the issues in the repo, like https://github.com/rickyah/ini-parser/issues/243, it made me think: does that mean that the library can either take ;
or any character, such as #
as comment string, but not mixing both in the same file?
Did you consider using the .NET version of the editorconfig core library (referenced from https://editorconfig.org/#create-a-plugin) https://github.com/editorconfig/editorconfig-core-net ? Maybe it is more tuned for the particularities of the format, and might be in a better chance of being maintained, as the ini-parser is in low maintenance https://github.com/rickyah/ini-parser/issues/237
@echoix I originally looked at using editorconfig-core-net, but it didn't support IFileSystem and my PR to add that has been sitting so it may also be in low maintenance - https://github.com/editorconfig/editorconfig-core-net/pull/24
Then I realized that they way editorconfig-core-net worked would probably also performance problems. I believe it creates a configuration per file, and with a repo with 10,000 files that could be problematic. I settled on using ini-parser, not realizing the defaults for how it parsed files didn't work with editorconfigs.
Ini-parser does support a comment regex, someone else caught that before 0.26.0 was released and as far as I know that is working. There is a test for it here
Are you using a global install of csharpier? I did just fix an issue related to that #1000, but I don't believe it was causing VS to hang. I'm hoping to improve a number of things in the extensions with #995 and one of them is going to be logging on the csharpier site to help understand situations like when csharpier seems to be hanging.
The solution of our main repo does not open properly after we updated from 0.25.0 to 0.26.0. VS freezes and shows an infinite loading circle. Another solution opens with high loading time and a warning message from VS regarding to the CSharpier extension.
If we disable the CSharpier extension everything works just fine.
Are you aware of this problem or have anyone an idea how we can fix it?