Is there a way to tell Visual Studio to show certain member values by default while in debug mode?

.net-4.0, c#, debugging, visual-studio, visual-studio-2013

Solution

This is the DebuggerDisplayAttribute

You can use it in your classes like

[DebuggerDisplay("Name = {Name}, Id = {Id}")]
public class MyClass
{
    public string Name { get; set; }
    public int Id { get; set; }
}

Problem

Certain .NET classes must have some kind of attribute set on either the class or individual members to tell it to show those members' values by default while hovering the mouse over an object in debug mode. Here's an example: Out of all the members in `Type`, only `Name` and `FullName` are shown while the object is fully collapsed. I'd like to do the same for some of my own classes so that I can have an entity's ID and Name members shown by default. Is there a way I can do this? Note: My question pertains to VS 2013, but it would be nice to know how to do this for earlier versions like 2010 or earlier for those using older versions. I am also using C# 4.0 just in case the method to achieve what I am doing differs between languages and .NET frameworks.

Original source

Related problems