codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.88k stars 353 forks source link

CodeMaid crashes on load with Microsoft Sarif Viewer Extension, VS 17.4.5 #979

Open echoix opened 1 year ago

echoix commented 1 year ago

Environment

Description

Replace this text with a short description and code sample. When opening a solution, the CodeMaid extension crashes. The activity log referenced includes a weird stack trace that mentions the sarif viewer extension, that I also have enabled, if I understand well.

Steps to recreate

  1. Open a Visual Studio solution, with the CodeMaid extension installed
  2. See the error.
  3. More than one solution (even samples downloaded from GitHub) can trigger this.
  4. The installation of the latest VS update was done yesterday, and crashes started yesterday.
  5. Disabling the Microsoft SARIF extension and reopening Visual Studio stopped the error message from appearing, even when loading a .cs file.

image image image image

I also saved the file locally, but kept it since there was some extra information (the ones that I blurred out).

\# | Type | Description | GUID | Hr | Source | Time (UTC) -- | -- | -- | -- | -- | -- | -- 1 |   | Microsoft Visual Studio 2022 version: 17.0.33402.68 |   |   | VisualStudio | 2023/02/22 16:33:03.430 ... |  ... | ... | ...  | ...  | ... | ... ... |  ... | ... | ...  | ...  | ... | ... 624 | ERROR | CreateInstance failed for package [CodeMaidPackage]Source: 'mscorlib' Description: Exception has been thrown by the target of an invocation. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: EnsurePane must be called on the UI thread. at Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(String callerMemberName) at Microsoft.Sarif.Viewer.OutputWindowTracerListener.EnsurePane() in D:\a\1\s\src\Sarif.Viewer.VisualStudio.Core\OutputWindowTracerListener.cs:line 65 at Microsoft.Sarif.Viewer.OutputWindowTracerListener.Write(String message) at System.Diagnostics.TraceInternal.WriteLine(String message) at SteveCadwallader.CodeMaid.CodeMaidPackage..ctor() in C:\projects\codemaid\CodeMaidShared\CodeMaidPackage.cs:line 93 --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)System.Runtime.InteropServices.COMException (0x8001010E): EnsurePane must be called on the UI thread. at Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(String callerMemberName) at Microsoft.Sarif.Viewer.OutputWindowTracerListener.EnsurePane() in D:\a\1\s\src\Sarif.Viewer.VisualStudio.Core\OutputWindowTracerListener.cs:line 65 at Microsoft.Sarif.Viewer.OutputWindowTracerListener.Write(String message) at System.Diagnostics.TraceInternal.WriteLine(String message) at SteveCadwallader.CodeMaid.CodeMaidPackage..ctor() in C:\projects\codemaid\CodeMaidShared\CodeMaidPackage.cs:line 93 | {4C82E17D-927E-42D2-8460-B473AC7DF316} | 0x80004005 - E_FAIL | VisualStudio | 2023/02/22 16:24:30.419

Current behavior

Explain what it's doing and why it's wrong. Crashes on loading solution.

Expected behavior

Explain what it should be doing after it's fixed. The extension can load normally without generating an error.

Config info

Click me ``` Microsoft Visual Studio Community 2022 Version 17.4.5 VisualStudio.17.Release/17.4.5+33403.182 Microsoft .NET Framework Version 4.8.09032 Installed Version: Community Visual C++ 2022 00482-90000-00000-AA922 Microsoft Visual C++ 2022 ASP.NET and Web Tools 17.4.337.25083 ASP.NET and Web Tools Azure App Service Tools v3.0.0 17.4.337.25083 Azure App Service Tools v3.0.0 Azure Functions and Web Jobs Tools 17.4.337.25083 Azure Functions and Web Jobs Tools C# Tools 4.4.0-6.23101.15+72dbad1d47f6065730a65c97621a4e93dc3efdf2 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. CodeMaid 12.0 CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. CreateUnitTestBoilerplateCommand Extension 1.0 CreateUnitTestBoilerplateCommand Visual Studio Extension Detailed Info Extensibility Message Bus 1.4.1 (main@2ee106a) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Linux Core Dump Debugging 1.0.9.33403 Enables debugging of Linux core dumps. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft SARIF Viewer 3.0.115.33558 Visual Studio Static Analysis Results Interchange Format (SARIF) log file viewer Mono Debugging for Visual Studio 17.4.19 (8c0a575) Support for debugging Mono processes with Visual Studio. NuGet Package Manager 6.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ NVIDIA CUDA 11.8 Wizards 11.8 Wizards to create new NVIDIA CUDA projects and source files. Razor (ASP.NET Core) 17.4.5.2306901+ce80d539513291a2065f47028bef14b497dc2443 Provides languages services for ASP.NET Core Razor. ResX Resource Manager ResXManager Manage localization of all ResX-based resources in one place. Shows all resources of a solution and lets you edit the strings and their localizations in a well-arranged data grid. SonarLint for Visual Studio 6.13.0.62767 SonarLint is an extension to your favorite IDE that provides on-the-fly feedback to developers on new bugs and quality issues injected into their code. StylerPackage Extension 1.0 StylerPackage Visual Stuido Extension Detailed Info Toggle Comment 2.1 This is a simple visual studio extension to comment/uncomment the selected lines. TypeScript Tools 17.0.10921.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 4.4.0-6.23101.15+72dbad1d47f6065730a65c97621a4e93dc3efdf2 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual C++ for Linux Development 1.0.9.33403 Visual C++ for Linux Development Visual F# Tools 17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b Microsoft Visual F# Tools Visual Studio File Histories VSHistory Maintains the history of all files saved in Visual Studio Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. Visual Studio Spell Check Everywhere VSSpellCheckEverywhere An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes. https://GitHub.com/EWSoftware/VSSpellChecker Visual Studio Spell Checker VSSpellChecker An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows. https://GitHub.com/EWSoftware/VSSpellChecker VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 17.4.0.315 (d17-4@beed03a) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 17.4.0.138 (remotes/origin/d17-4@d36bba3cc9) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 17.4.2 (c457c97) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. ```
kyle-rudd commented 1 year ago

I believe I am seeing the same issue, running with Visual Studio 2022 Professional, UWP, and XamlStyler installed. When I uninstall XamlStyler the error stops happening. Also, this seems to happen more often with very large solutions.

I get a very similar exception in ActivityLog.xml, see attached for entry. CodeMaid Error.txt

echoix commented 1 year ago

I am able to keep XamlStyler active though

kyle-rudd commented 1 year ago

That's a good point. I only get the error on one of my dev computers, the other computer with XamlStyler and CodeMaid seems to behave correctly.

codecadwallader commented 1 year ago

Thanks both for reporting the issue. If I understand correctly, it only happens if the Microsoft Sarif Viewer Extension is installed but works as expected with other extensions like XamlStyler?

echoix commented 1 year ago

Thanks both for reporting the issue. If I understand correctly, it only happens if the Microsoft Sarif Viewer Extension is installed but works as expected with other extensions like XamlStyler?

No issue with XamlStyler indeed. I didn't recheck with later versions of Visual Studio now, I just kept the Sarif Viewer off as I didn't need it.

kyle-rudd commented 1 year ago

It does appear to be an issue with Sarif Viewer specifically. Same as echoix, I am ok with not using it as a work around.