Custom visual debugging tools (Microsoft. VisualStudio. DebuggerVisualizers) and debugger debugging
Preface:
There have been too many lost planes recently. We will fly to Beijing tomorrow to handle the problem of dual-host hot backup on servers. We have bought the aviation insurance Ticket No.: TF10122913.
As for my bank card password, In the Note below my pillow, if I haven't updated the document, please inform my family, Hahahaha.
Okay. After Joke is played, Enter the text below.
Background: CYQ. when Data is used, MDataTable objects are often broken. To view the Data content of a table, ToDataTable () is often used in monitoring, and tables can be viewed visually by DataTable.
Recently: I came up with a sentence in my mind. Can't I do it without changing my mind? Looking at the MDataTable object directly, Like This:
Visual debugging tool (Microsoft. VisualStudio. DebuggerVisualizers)
It is too powerless to describe in words. I am direct and intuitive:
A: visualized debugging of strings:
The visual debugging tool (Microsoft. VisualStudio. DebuggerVisualizers) doesn't mean that you think it is very complicated, but it is actually very simple. Here we will take an example of the Image System. Draw. Image. The final effect is as follows:
Microsoft. VisualStudio. DebuggerVisualizers
Step 3: Enter the following code: using Microsoft. VisualStudio. DebuggerVisualizers;
Using System;
Using System. Drawing;
Using System. Windows. Forms;
[Assembly: System. Diagnostics. DebuggerVisualizer (
Typeof (CYQ. Visualizer. ImageVisualizer ),
Typeof (VisualizerObjectSource ),
Target = typeof (System. Drawing. Image ),
Description = "Image Visualizer")]
Namespace CYQ. Visualizer
{
Public class ImageVisualizer: DialogDebuggerVisualizer
{
Override protected void Show (IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
Image image = (Image) objectProvider. GetObject ();
Form form = new Form ();
Form. Text = string. Format ("Width: {0}, Height: {1}", image. Width, image. Height );
Form. ClientSize = new Size (image. Width, image. Height );
Form. FormBorderStyle = FormBorderStyle. FixedToolWindow;
PictureBox pictureBox = new PictureBox ();
PictureBox. Image = image;
PictureBox. Parent = form;
PictureBox. Dock = DockStyle. Fill;
WindowService. ShowDialog (form );
}
}
} Then compile the program into a Xxx. dll file, and then click OK.
A brief description of the Code process: 1: Create a class named XXXX and inherit from: DialogDebuggerVisualizer
2: override method Show (with two parameters)
3: In the code, the first line: objectProvider. GetObject () returns the copy of the object of the class you want to process. You can perform type conversion.
It is explained that the processing must be serialized.
4: The last line: windowService. ShowDialog (control); displays a control. We usually use Form to display it.
5: the middle part is the self-defined presentation, and the content we want to write is the same. You will learn Winform knowledge.
6: In the last step, specify the assembly information to be reflected by the plug-in: There are three typeof
The first typeof (that is, the XXXX class) The second typeof (by example, unless you need to customize your own serialization) The third typeof (the class you want to visualize) 3: how to deploy: Visual debugging tool (Microsoft. visual Studio. debuggerVisualizers)
Put the Xxx. dll in the following directory: VS installation directory \ Microsoft Visual Studio XXX \ Common7 \ Packages \ Debugger \ Visualizers
Then it takes effect automatically. When debugging, it will be loaded to present your effect.
4: source code download and description
For different VS versions (2005, 2008, 2012, and 2015), you need to compile different versions of idea, which are mainly referenced by Microsoft. VisualStudio. DebuggerVisualizers.
: CYQ.Visualizer.rar download