EgorBo / Disasmo

VS2022 Add-in. Click on any method or class to see what .NET Core's JIT generates for them (ASM).
MIT License
656 stars 41 forks source link

VS results in an exception when Alt+Enter (suggested code fix) is pressed with Disasmo installed #9

Closed Gnbrkm41 closed 4 years ago

Gnbrkm41 commented 4 years ago
  <entry>
    <record>698</record>
    <time>2020/02/09 19:41:59.921</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.InvalidOperationException: Can only compare ISuggestedActionCategories defined with SuggestedActionCategoryRegistryService&#x000D;&#x000A;   at Microsoft.VisualStudio.Language.Intellisense.Implementation.SuggestedActionCategoryComparer.Compare(String x, String y)&#x000D;&#x000A;   at System.Linq.EnumerableSorter`2.CompareKeys(Int32 index1, Int32 index2)&#x000D;&#x000A;   at System.Linq.EnumerableSorter`1.QuickSort(Int32[] map, Int32 left, Int32 right)&#x000D;&#x000A;   at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)&#x000D;&#x000A;   at System.Linq.OrderedEnumerable`1.&lt;GetEnumerator&gt;d__1.MoveNext()&#x000D;&#x000A;   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()&#x000D;&#x000A;   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)&#x000D;&#x000A;   at Microsoft.VisualStudio.Language.Intellisense.Implementation.DefaultLightBulbPresenterDefaultIconUIElementProvider.GetUIElement(ISuggestedActionCategorySet itemToRender, ILightBulbSession context, UIElementType elementType)&#x000D;&#x000A;   at Microsoft.VisualStudio.Language.Intellisense.Implementation.LightBulb..ctor(LightBulbSession session, LightBulbPresenterStyleFactory presenterStyleFactory)&#x000D;&#x000A;   at Microsoft.VisualStudio.Language.Intellisense.Implementation.LightBulbTagger.&lt;Microsoft.VisualStudio.Text.Tagging.ITagger&lt;Microsoft.VisualStudio.Language.Intellisense.Implementation.LightBulbTag&gt;.GetTags&gt;b__10_1()&#x000D;&#x000A;   at Microsoft.VisualStudio.Language.Intellisense.Implementation.LightBulbTag.get_Glyph()&#x000D;&#x000A;   at Microsoft.VisualStudio.Language.Intellisense.Implementation.LightBulbGlyphFactory.GenerateGlyph(IWpfTextViewLine line, ISuggestionTag tag)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.CanvasAndGlyphFactory`1.GenerateGlyph(IWpfTextViewLine line, ITag tag)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.GlyphMarginVisualManager`1.AddGlyph(TGlyphTag tag, SnapshotSpan span)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.GlyphMargin`1.RefreshGlyphsOver(ITextViewLine textViewLine)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.GlyphMargin`1.OnBatchedTagsChanged(Object sender, BatchedTagsChangedEventArgs e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
  </entry>

I'm using VS2019 16.5 P2, but it used to happen with P1 as well. Can't confirm if it happened before. It appears that this only happens when Alt+Enter (or Ctrl + .) is pressed; this also does not happen with Disasmo disabled / uninstalled.

kindermannhubert commented 4 years ago

I have exactly same problem.

I had suspicion it's interfering with some other extension. So I disabled all other VS extensions but problem remained. With all other extensions disabled a even reinstalled Disasmo but didn't help.

Using VS 16.4.5. Project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>
</Project>

Code:

using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine();
        }
    }
}

Click on Main and press "Ctrl+.". Result is just exception described above. No actions will be available (not event default IDE suggestions).

EgorBo commented 4 years ago

Ouch doesn't sound good, @Gnbrkm41 @kindermannhubert when you mention Alt+Enter/Ctrl+"." do you mean Roslyn actions or maybe you have R# installed?

Gnbrkm41 commented 4 years ago

I do not have R# installed, and yes it is the Roslyn actions.

EgorBo commented 4 years ago

@sharwell maybe it sounds familiar to you? I have no idea how my extension messes things up in VS2019 so the problem remains even if it's disabled/uninstalled 🙁🙁

updated all dependencies just in case, maybe will help (I can't repro the issue)

kindermannhubert commented 4 years ago

@EgorBo Sorry, maybe I wasn't clear enough - when I disable Disasmo VS works just fine. I was trying to disable all extensions except Disasmo to find out if it helps but it does not. I do not have R# too.

kindermannhubert commented 4 years ago

Last update didn't help.

Interestingly when I don't use keyboard to trigger the actions it works (just click on 'Main' and click on light bulb): image but when I press Ctrl+. it will fail (even after successful opening of Disasmo window with mouse): image

Gnbrkm41 commented 4 years ago

Same here. The exception also seems to prevent opening the roslyn actions window with the shortcut unless VS is restarted.

kindermannhubert commented 4 years ago

Now works fine for me. Thanks.

EgorBo commented 4 years ago

Closed in https://github.com/EgorBo/Disasmo/pull/10