Solved

Displaying values as tooltip in debugger

Posted on 2014-04-25
7
240 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 75

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 75

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 75

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

25 Experts available now in Live!

Get 1:1 Help Now