After completing this topic, you should be able to use a DataTip to edit a member of a complex data type and use Debugger Display attributes to modify how information is presented in the Visual Studio 2005 debugger.
In this exercise, you're required to use a DataTip to edit a member of a complex data type, and use debugger display attributes to modify how information is presented in the Visual Studio 2005 debugger.
This involves the following tasks:
Suppose you're currently debugging a short application. You notice an incorrect value in the code, and decide to replace this value using the extended DataTips feature in Visual Studio 2005 so that you can view the altered output.
You want to change the name of the p1
code item to "Pears". You have already accessed the DataTip for p1
by hovering your cursor over it in the code.
Which steps do you perform to change the name of the variable using its DataTip?
Options:
To change the name of the p1
variable using its DataTip, you click the + icon, click the "Apples" entry, type Pears
, and press Enter twice.
While debugging an application, you decide that you want to change the way types are displayed in the debugger windows.
You decide to change the display properties of a string, which you have named "value".
Complete the code required to do this.
[MISSING CODE("{value}")]
internal class KeyValuePairs
{
private IDictionary dictionary;
private object key;
private object value;
public KeyValuePairs(IDictionary dictionary, object key, object value)
{
variables(value, key & dictionary);
this.value = value;
this.key = key;
this.dictionary = dictionary;
}
}
You use DebuggerDisplay
to alter the display properties of a string.
When a type occurs at class level, you want the debugger to display a value of 50 in the value column in the debugger variable windows.
Which display attribute do you use to do this?
Options:
You use the DebuggerDisplay
attribute to customize how a type displays at class level.
Option 1 is correct. The DebuggerDisplay
attribute controls how a member or type is displayed in the debugger variable windows and is applied at class level.
Option 2 is incorrect. The DebuggerHidden
attribute is used by source code debuggers to hide code from the debugger.
Option 3 is incorrect. The DebuggerNonUserCode
attribute identifies system code – code that the system, rather than a user, created. In Visual Studio 2005, enabling the Just My Code feature will prevent the debugger from displaying this code in debugger windows, unless the code contains an error.
You want a specific type to display only public members in the debugger variable windows. However, you want to change the view of the type, without altering the type itself.
Which attribute do you use to do this?
Options:
You use the DebuggerTypeProxy
attribute to set the display proxy for a type, which will display only public members and won't change the type itself.
Option 1 is incorrect. The DebuggerDisplay
attribute is applied at class level and controls how a member or type is displayed in the debugger variable windows.
Option 2 is incorrect. You use the DebuggerStepThrough
attribute to tell the debugger to step through certain code, so that the code doesn't display in debugger windows – provided the Just My Code feature is enabled.
Option 3 is correct. You use the DebuggerTypeProxy
attribute to customize the view of a type, without altering it, by specifying a display proxy for it. The debugger variable windows will then display only public members of the proxy.
The extended DataTips feature has now been used to edit the values in a complex data type, and debugger display attributes have been used to alter the way that types display in debugger windows.
Copyright © 2006 SkillSoft. All rights reserved.
SkillSoft and the SkillSoft logo are trademarks or registered trademarks
of SkillSoft in the United States and certain other countries.
All other logos or trademarks are the property of their respective owners.