Sunday, February 6, 2011

Fun with autoexp.dat in Visual Studio

I decided to add some auto expansion for debugging various classes in my project, the simplest of which just expose the object name more or less...



DataType=<typename.elements,s>
Property=<name.elements,s>
AObject=<objname.elements,s> [Type: <objtype>]


Works well enough but doesn't look so great when you're uninitialized or otherwise invalid data, at which point enter the obtuse syntax of visualizers...

TString{
preview (
#if ($e.Elements == 0) ( "null" )
#else ( [$e.Elements,s] )
)
}

Simple enough, if it's a null pointer then show "null" instead of the default error text.  Now for something slightly more entertaining...

ObjectType{
preview (
#if ($e.SuperType == 0) (
[$e.TypeName.Elements,s]
) #else (
#(
[$e.TypeName.Elements,s],
" [",
*$e.SuperType,
"] "
)
)
)
}

Make sure you don't mess up your pairings as you'll have to restart Visual Studio and a debugging session to figure out if you got it right or not.  Oh and the documentation for the syntax apparently exists solely as examples for other types (mainly STL) in the autoexp.dat file itself.

No comments:

Post a Comment