title: Visual Studio Visualizer for IEnumerable<string>
body: <p><strong>TL;DR</strong><br>
  Does anyone know how to write a Debug Visualizer for Visual Studio 2012, in C#, so I can visualize <code>IEnumerable&lt;string&gt;</code>, <code>string[]</code> or similar objects?  </p>
  
  <p><strong>More Info</strong><br>
  Visual Studio Debug Visualizer are great, and I use some popular ones (<a href="http://www.molosoft.com/" rel="nofollow">Mole</a>) regularly.
  However, now the time has come to roll out some custom visualizers. I started off with a simple visualizer for a string:</p>
  
  <pre><code>[assembly: System.Diagnostics.DebuggerVisualizer(typeof(My.Namespace.DebuggerSide),
                                              typeof(VisualizerObjectSource),
                                              Target = typeof(string),
                                              Description = "Awesome Visualizer")]
  </code></pre>
  
  <p>the code of DebuggerSide is basically the example from the template:</p>
  
  <pre><code>public class DebuggerSide : DialogDebuggerVisualizer
  {
      protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
      {
          if (windowService == null)
              throw new ArgumentNullException("windowService");
          if (objectProvider == null)
              throw new ArgumentNullException("objectProvider");
  
  
          var data = (string)objectProvider.GetObject();
  
          using (var displayForm = new VisualizerForm(data))
          {
              windowService.ShowDialog(displayForm);
          }
      }
  
      /// &lt;summary&gt;
      /// Tests the visualizer by hosting it outside of the debugger.
      /// &lt;/summary&gt;
      /// &lt;param name="objectToVisualize"&gt;The object to display in the visualizer.&lt;/param&gt;
      public static void TestShowVisualizer(object objectToVisualize)
      {
          VisualizerDevelopmentHost visualizerHost = new VisualizerDevelopmentHost(objectToVisualize, typeof(DebuggerSide));
          visualizerHost.ShowVisualizer();
      }
  }
  </code></pre>
  
  <p><code>VisualizerForm</code> is the custom form with extra controls etc...
  when I build the project and put the dll in the <code>My Documents/Visual Studio 11/Visualizers</code> folder, and restart visual studio, I can indeed see the debugger appearing under the looking glass icon when a breakpoint is hit for a string object. Woohoo! So far so good.</p>
  
  <p>Now I would like to, instead of visualizing <code>string</code>, visualize <code>string[]</code> or <code>IEnumerable&lt;string&gt;</code> or a similar object. However when I change the assembly attribute to <code>IEnumerable&lt;string&gt;</code>, this is not working, there is not even a looking glass icon displayed on the IEnumerable objects.</p>
  
  <p><strong>UPDATE</strong><br>
  I can get it to work by changing the TargetType to <code>List&lt;&gt;</code> and then checking if I can cast to <code>List&lt;string&gt;</code>. However, this means I have to cast all my objects I want to debug to <code>List</code> and can't use <code>IEnumerable&lt;&gt;</code> or string[]</p>