Solved

Displaying values as tooltip in debugger

Posted on 2014-04-25
7
238 Views
Last Modified: 2014-04-25
I'm using VS 2008, Visual Basic. When I'm in debug mode, if I hover the mouse over a variable, the variable's value displays in a tooltip box. However, that doesn't happen if the variable is qualified with a dot, whether to call a property (ThisForm.Width) or to execute a method (ThisDate.AddDays(1)). I can right-click on the variable and choose Add Watch, which displays the value in the Watch window, but that's tedious and quickly builds up a large list of variables to display.

Is there any way to get the tooltip display to work for variables with dots and members after the name?
0
Comment
Question by:ElrondCT
  • 3
  • 3
7 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40023641
I'm afraid I'm not sure what you mean. Mousing over properties works fine for me:

Screenshot
Now method calls are different because methods have to actually be executed in order to see their values. You can paste method calls (as well as properties) into the Immediate Window (Debug->Windows->Immediate), and prepend the call with a question mark to inspect its value.

e.g.

Screenshot
0
 
LVL 20

Author Comment

by:ElrondCT
ID: 40023662
Oops, you're right. Properties are visible. However, if a method is called, no tooltip is available, either for the result of the method or for the original variable or control. Yes, I can display it in the Immediate window (or the Watch window, as I mentioned), but I was wondering if I was missing a more direct way to view them. Particularly if it's a control or a datatable/dataset, the display windows are less than ideal; the dataset visualizer, for instance, isn't available at all.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40023689
VB isn't my main langauge, and it's been a good while since I've done active development in it, so please wait for additional responses. One alternative I can think of--and it will take some upfront investment--would be to have properties that call your method behind the scenes. You could include conditional compilation in your project to only build such properties for your development version. As I said, there would be an investment because you'd now have to write a property for each method you care about. Less than ideal, but if you really need it versus using Watch or Immediate Window...

e.g.

Module Module1

    Sub Main()
        Dim x As New Test()

        Console.WriteLine(x.ThisTest)
        Console.WriteLine(x.ATest())

    End Sub

End Module


Public Class Test
    Public Property ThisTest()
        Get
            Return "hello world!"
        End Get
        Set(ByVal value)

        End Set
    End Property

    Public Function ATest() As String
        Return "Hello World!"
    End Function

#If DEBUG Then
    Public ReadOnly Property DBG_ATest() As String
        Get
            Return Me.ATest()
        End Get
    End Property
#End If
End Class

Open in new window


Screenshot
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 40023695
P.S.

I suspect the reason why you don't get tooltips for methods but you do for properties is because even though properties technically get compiled into methods during the build, the assumption is that properties only provide data access--there are no side effects to worry about when accessing a property...at least there aren't supposed to be. With a method, depending on how it is written, the method could mutate the internal state of the object on each call to the method. As I said before, methods have to be executed, so the act of showing the method's return value in a tooltip would cause the method to execute. If the method was a mutator method, then you would be modifying your object's state every time you viewed the tooltip. Very less than ideal!

P.P.S.

Using the conditionally-compiled property that I demonstrate above would have an equivalent effect as the mutator method I mention above, if the underlying method being called is a mutator method.
0
 
LVL 20

Author Comment

by:ElrondCT
ID: 40023717
Thanks, Kaufmed, but I'm looking for something generalized, not for a specific item, the same way that mousing over variables (that don't have methods attached) allows me to quickly view the current values.

Yes, I can easily see how executing methods in the middle of a display could cause problems, though they do work in a Watch window. I'd really be perfectly happy seeing the value for the underlying object with no method activity (IOW, what I'd see now if the method weren't attached). There is, no doubt, ambiguity there--are you seeing the variable, or the result of the method--but as long as it's consistently displayed, I don't see that that should be a problem. This may be more a wishlist item; I just wondered if there was some way to get there already that I was unaware of.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40023733
There is a more direct way of having the result of a method, that won't fill up you Watch window. It's the Quick Watch, available through a right click on the call, or Shift-F9 when the cursor is on it.
0
 
LVL 20

Author Comment

by:ElrondCT
ID: 40024052
Ah, that's it! Quick Watch does exactly what I want--it displays the underlying object that I click on, and I can see all properties, or with a dataset, I can view the dataset visualizer. Thanks!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now