I have found that certain types when present in DebuggerVisualizerAttribute
prevent showing all visualizers. Not only the one in which they are present but all with exception of the most generic ones (Text, XML, JSON, HTML). Even the DataTable visualizer is blocked. So far I have identified SortedList<int,string>
, DataRow[]
(array of Datarow) and many others.
I need to exclude those types from generated list of types (for visualizing an interface). I did not managed to get any error message (debugging output, ActivityLog.xml, debugging the Visual Studio with other instance of it, WinDbg was not tested).
Steps to reproduce the behavior
I use VS2017,.NET 4.7.1, W 10 x64 EN (I didn't notice the problem on VS2012,.NET 4.5 W 7, but it was reproduced in VS2015)
- Create a debugger visualizer for string and test it (For example Walkthrough: Writing a Visualizer in C#, Walkthrough: Writing a Visualizer in Visual Basic but probably any other visualizer will do)
- Install the visualizer (copy to My Documents\ VisualStudioVersion \Visualizers - How to: Install a Visualizer)
- Start debugging in Visual Studio and check that the created visualizer is offered (I recommed also checking presence of the magnifying glass for DataTable)
- Add one of following attributes to the visualizer code:
[assembly: System.Diagnostics.DebuggerVisualizer(typeof(MyFirstVisualizer.DebuggerSide), typeof(VisualizerObjectSource), Description = "Failing1",
Target = typeof(System.Collections.Generic.SortedList<int, string>))]
[assembly: System.Diagnostics.DebuggerVisualizer(typeof(MyFirstVisualizer.DebuggerSide), typeof(VisualizerObjectSource), Description = "Failing2",
Target = typeof(System.Data.DataRow[]))]
or vb.net
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(MyFirstVisualizer.DebuggerSide), GetType(VisualizerObjectSource), Description:="Failing1",
Target:=GetType(System.Collections.Generic.SortedList(Of Integer, String)))>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(MyFirstVisualizer.DebuggerSide), GetType(VisualizerObjectSource), Description:="Failing2",
Target:=GetType(System.Data.DataRow()))>
- Install modified visualizer and test that it is not offered and magifying glass for DataTable is missing (it is necessary to restart debugging but not the Visual Studio)
Partial solution
I have noticed that most of problem types are Constructed Generic Types and I magaged get rid of the problem with excluding types with .IsGenericType
and .IsConstructedGenericType
.
I did not wrote the solution as an answer because Dictionary<int,string>
does not cause the problem and DataRow[]
is not a Constructed Generic Type.
Notes
- When Options > Debugger > General > Use Managed Compatibility Mode is ticked. The problem cannot be reproduced (txh Hans Passant).
- The question was edited to include less obscure types and a partial solution.
- I did not manage adding winforms reference to net standard dll so I used .Net Framework for creating visualizer in 1.
- The problem is now reported to Microsoft: Certain types prevent showing all custom Debugger Visualizers