Yes you can. One of options is to use DebuggerDisplayAttribute
Debugger display attributes allow the developer of the type, who specifies and best understands the runtime behavior of that type, to also specify what that type will look like when it is displayed in a debugger.
[DebuggerDisplay("The count value in my class is: {count}")]
class MyClass
{
public int count { get; set; }
}
EDIT: After explanation I understood what you want. It is possible to do your custom multi-line visualiser, but you probably don't like the way of doing it :)
- You need to add the reference to
Microsoft.VisualStudio.DebuggerVisualizers.dll
. I found it in Add Reference -> Assemblies -> Extensions list
- Your need to create new class and inherit DialogDebuggerVisualizer class. Override Show method and display the required content.
- Mark your class as
Serializible
- Add reference to your custom Visualizer
Here is the sample code:
using System.Windows.Forms;
using Microsoft.VisualStudio.DebuggerVisualizers;
[assembly: DebuggerVisualizer(typeof(MyClassVisualizer), Target = typeof(MyClass), Description = "My Class Visualizer")]
namespace MyNamespace
{
[Serializable]
public class MyClass
{
public int count { get; set; } = 5;
}
public class MyClassVisualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
MyClass myClass = objectProvider.GetObject() as MyClass;
if (objectProvider.IsObjectReplaceable && myClass != null)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Here is");
sb.AppendLine("your multi line");
sb.AppendLine("visualizer");
sb.AppendLine($"of MyClass with count = {myClass.count}");
MessageBox.Show(sb.ToString());
}
}
}
}
Then you will see magnifier and when you click it the result will look like this:
