Watch Display - Mimic Default Types...

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Well,

Some may or may not agree with my mentality behind this, but I found it rather annoying (and somewhat self-defeating) the nature of Size and Point.

You can Add a Size to a Point, but you can't add a Point to a Point. Given that they are both structures of two integers, representing a horizontal and vertical measurement (either a Cartesian location, or a physical dimension).

So I wrote in my own universal Coord structure, that pretty much does everything. Add, subtract, multiply, divide, from any other Coord structure, or the singular integer as well, and the conversions are all Widening, so from Coord to Size, Coord to Point, Point to Coord, Size to Coord, just happens intrinsically. And it is very nice. I do so like it.

But, while stepping through my program i've noticed that unlike my Coord structure, the Size structure is displayed in the Watch Window like this:
VB.NET:
+		Me.Size	{Width = 150 Height = 50}	System.Drawing.Size
But My Coord Structure is Displayed like this:
VB.NET:
+		szf	{FlufLib.CoordF}	FlufLib.CoordF

Now, I have pretty much used the Reflector app to see exactly how the Size structure is defined, and tried to mimic it exactly. Though, I will say that the Reflector is either wrong, or VB cheats, because the reflector says that the Size structures field and properties have the EXACT same names, which the vb compiler won't let me do for my Structure.

Granted in the case of the above "size" type, I am referencing the Form's Size property, but on the whole, I am curious as to how that is setup in such a manner as to give the values. I would very much like to be able to have my Watch's structure types (or some class types for that matter) display in such a fashion as:
VB.NET:
+		szf	{X = 150.0 Y=13.852}	FlufLib.CoordF

Is this even possible to achieve with user generated code?

Thanks
 
you can't add a Point to a Point
Point.Offset
I will say that the Reflector is either wrong, or VB cheats, because the reflector says that the Size structures field and properties have the EXACT same names
They are not exactly the same, they differ by case, which VB language don't support, so when it display the disassemblies for VB it doesn't bother changing it.
how that is setup in such a manner as to give the values
solution courtesy of Calvin Hsia's WebLog : Write simple Debug helpers to help you debug and maintain your code, add DebuggerDisplay attribute to the structure and override the ToString method:
VB.NET:
<DebuggerDisplay("{ToString}")> _
 
Back
Top