Skip to content

Debugging the DOM with Visual Studio

Gary edited this page Aug 27, 2014 · 1 revision

Table of Contents

The DomNode class has the _DebugInfo property that gathers information about the node's contents and formats it so the information is easier to access. The illustration shows this property for a DomNode:

/images/Dom debugging 2.png

Note that the value of the DomNode itself (this) shows a hash code along with the node's DomNodeType. Hash codes are the equivalent of unique IDs for the current debugging session; they are unique to the AppDomain, the application domain that is an isolated environment where applications execute.

The _DebugInfo property contains several categories of information, shown in the figure. You can also open nodes under _DebugInfo in the debugger to get more information on the displayed data.

DomNode Event Listeners

You can find out what objects subscribe to any of the six DomNode events listed under _DebugInfo:

  • AttributeChanged under AttributeChangedListeners.
  • AttributeChanging under AttributeChangingListeners
  • ChildInserted under ChildInsertedListeners
  • ChildInserting under ChildInsertingListeners
  • ChildRemoved under ChildRemovedListeners
  • ChildRemoving under ChildRemovingListeners
The Value column shows how many listeners there are for each event. Opening any of the listener nodes shows an array of all listeners, in the order in which they receive events. In the figure above, the opened ChildInsertingListeners node shows one listener, which is the DOM adapter MasteringValidator. Opening the listener node reveals the method called when the event occurs and the Target, which is the listener itself.

DomNode Attributes

The Attributes node lists all the attributes' names and values:

  • AttributeInfo's string value for the name.
  • GetAttribute()'s string value for the value.
The open node under "Attributes" in the figure also shows the name and value. If there is no "local" value, the default value is displayed.

DomNode Children

The Children node displays the DomNode children's names and values, if any:

  • ChildInfo's string value for the name.
  • Child DomNode's string value for the value.
The open node in the figure also shows the name and value.

DomNode Extensions

All extensions defined for the DomNode's type are also listed, including their count, as shown in this figure:

/images/Dom debugging 3.png

The value has three parts:

  • The extension name, which is nearly always a DOM adapter.
  • The HashCode of the DomNode.
  • The DomNodeType of the DomNode.

Enhancing Visual Studio

The information under _DebugInfo is provided by creating new classes in DomNode and marking these classes with special attributes. You can use these techniques to enhance the display of your own classes and data. For details, see Visual Studio Debugger Display Attributes and Other Features.

Topics in this section

Clone this wiki locally