Solved

Displaying values as tooltip in debugger

Posted on 2014-04-25
7
243 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 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