
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
430
|
Chapter 7: Exception Handling
if (!ignoreAssemblies.Contains(t.Assembly.FullName))
{
if (!assembliesReferenced.Contains(t.Assembly))
{
writer.WriteLine("//Adding for assembly " +
t.Assembly.FullName);
assembliesReferenced.Add(t.Assembly);
}
WriteDebuggerVisualizerAttribute(t, writer);
}
}
writer.WriteLine("");
writer.WriteLine("");
writer.WriteLine("// Add references for these assemblies");
foreach (Assembly assm in assembliesReferenced)
{
writer.WriteLine("// {0}", assm.FullName);
}
writer.Flush( );
writer.Close( );
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString( ));
}
}
The WriteDebuggerVisualizerAttribute method is shown here:
public static void WriteDebuggerVisualizerAttribute(Type t, StreamWriter writer)
{
// Write out the debugger visualizer attrib for this exception type
writer.WriteLine("");
writer.WriteLine("[assembly: System.Diagnostics.DebuggerVisualizer(");
writer.WriteLine("typeof(ExceptionalVisualizer.ExceptionVisualizer),");
writer.WriteLine("typeof(VisualizerObjectSource),");
writer.WriteLine("Target = typeof(" + t.FullName + "),");
writer.WriteLine("Description = \"Exception Visualizer\")]");
writer.WriteLine("");
}
Once the ExceptionSupport.cs file is created, it is built into the class library contain-
ing the visualizer, and then the visualizer ...