icsharpcode / AvaloniaILSpy

Avalonia-based .NET Decompiler (port of ILSpy)
1.5k stars 169 forks source link

Fix crash if SpecialFolder.ApplicationData doesn't exist #143

Open agocke opened 11 months ago

agocke commented 11 months ago

If the folder doesn't exist, the config variable will be 'ILSpy.xml', and the parent directory name will be an empty string. This will cause CreateDirectory to throw, and the application to potentially crash due to an exception in a background thread. This manifests as a native crash, NSInternalInconsistencyException, on my machine, with the message 'Terminating app due to uncaught exception 'NSInternalInconsistencyException',reason: 'NSWindow drag regions should only be invalidated on the Main Thread'.

By passing 'DoNotVerify' to Environment.GetFolderPath we can avoid the check for directory existence and avoid the crash.

agocke commented 11 months ago

VSCode removed all trailing whitespace here as well -- you can ignore that if you want.

agocke commented 11 months ago

Fixes https://github.com/icsharpcode/AvaloniaILSpy/issues/117

agocke commented 11 months ago

fyi @christophwille

christophwille commented 11 months ago

To be honest, I have a hard time connecting the crash with that fix, and I have no way to verify it either. So I will punt on merging this until this repository has a maintainer again.