The [DebuggerDisplay] attribute ( Using DebuggerDisplayAttribute ) allows you to define the display in the VS 2010/2008 debugger. By modifying AutoExp.cs / .dll, I can even override the display of system types and third-party types, for example.
[assembly: DebuggerDisplay (@"\{Name = {Name} FullName = {FullName}}", Target = typeof (Type))]
In inner braces, I can refer to fields, properties, and methods. Can I refer to extension methods ?
As an example, I tried to display shorter type names, for example. $SCG.Dictionary
instead of System.Collections.Generic.Dictionary
. I added this to AutoExp.cs:
using DbgDisp; [assembly: DebuggerDisplay (@"\{Name = {Name} ShortName = {ShortName()}}", Target = typeof (Type))] namespace DbgDisp { public static class Ext { public static string ShortName (this Type t) { return string.Format ("[{0}]", t.Name); } }
but the debugger complains: the name "ShortName" does not exist in the current context.
Am I missing something, or is it just impossible to use extension methods there?
I know that I can override ToString ()
, but this only helps for my own types.
source share