Skip to content

Exception when analyzing source of library with global assembly attributes. #3142

@SylwesterZarebski

Description

@SylwesterZarebski

Steps to reproduce

  1. Open some library which have classes used in global assembly attributes like:
[assembly: My(typeof(MyClass))]

where MyAttribute is Attribute defined as:

[AttributeUsage(AttributeTargets.Assembly)]
  1. Use Analyze on MyClass class.
  2. Above usage is shown in Used By tree:
    obraz
  3. Trying to double click or right click shows exception window.

Error message shown

On double click:

---------------------------
Sorry, we crashed
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
   at ICSharpCode.ILSpy.Analyzers.AnalyzerEntityTreeNode.ActivateItem(RoutedEventArgs e) in D:\a\ILSpy\ILSpy\ILSpy\Analyzers\AnalyzerEntityTreeNode.cs:line 39
   at ICSharpCode.TreeView.SharpTreeViewItem.OnMouseLeftButtonUp(MouseButtonEventArgs e) in D:\a\ILSpy\ILSpy\SharpTreeView\SharpTreeViewItem.cs:line 117
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

On right click:

---------------------------
Sorry, we crashed
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
   at ICSharpCode.ILSpy.ScopeSearchToNamespace.GetNamespace(TextViewContext context) in D:\a\ILSpy\ILSpy\ILSpy\Commands\ScopeSearchToNamespace.cs:line 76
   at ICSharpCode.ILSpy.ScopeSearchToNamespace.IsVisible(TextViewContext context) in D:\a\ILSpy\ILSpy\ILSpy\Commands\ScopeSearchToNamespace.cs:line 62
   at ICSharpCode.ILSpy.ContextMenuProvider.<>c__DisplayClass18_0.<ShowContextMenu>g__BuildMenu|0(Lazy`2[] menuGroup, ItemCollection parent) in D:\a\ILSpy\ILSpy\ILSpy\ContextMenuEntry.cs:line 314
   at ICSharpCode.ILSpy.ContextMenuProvider.ShowContextMenu(TextViewContext context, ContextMenu& menu) in D:\a\ILSpy\ILSpy\ILSpy\ContextMenuEntry.cs:line 0
   at ICSharpCode.ILSpy.ContextMenuProvider.treeView_ContextMenuOpening(Object sender, ContextMenuEventArgs e) in D:\a\ILSpy\ILSpy\ILSpy\ContextMenuEntry.cs:line 247
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Controls.PopupControlService.RaiseContextMenuOpeningEvent(IInputElement source, Double x, Double y, Boolean userInitiated)
   at System.Windows.Controls.PopupControlService.ProcessMouseUp(Object sender, MouseButtonEventArgs e)
   at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(Tuple`2 postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Details

  • Product in use: ILSpy
  • Version in use: 8.2.0.7535

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions