Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Visual Studio Debug View (value column / hover pop up tooltip) custom content: DebuggerDisplay

Visual Studio Debug View (value column / hover pop up tooltip) custom content: DebuggerDisplay

Scheduled Pinned Locked Moved Visual Basic
debuggingcsharpvisual-studiocomtutorial
7 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    in9mar
    wrote on last edited by
    #1

    Hi, in the Visual Studio Debug View value column (same as the debug mode hover pop up tooltip) I find it inefficient that for variables of compound types only the type name is displayed and to get to any state information I need to expand the display (click on plus icon). I found an example image here: http://www.davidhayden.com/photos/defaultdebuggervisualizer.jpg I'd love to control what goes into the string currently displaying the type name, like a function or property that, if implemented, overrides the default debugger class type display. I.e. in the image above I'd want to replace the "{Ecommerce.Shoppingcart}" with the output of Ecommerce.Shoppingcart.ToString(). Any idea if and how this is possible? Thanks, Ingmar

    modified on Monday, November 10, 2008 3:00 PM

    J S K 3 Replies Last reply
    0
    • I in9mar

      Hi, in the Visual Studio Debug View value column (same as the debug mode hover pop up tooltip) I find it inefficient that for variables of compound types only the type name is displayed and to get to any state information I need to expand the display (click on plus icon). I found an example image here: http://www.davidhayden.com/photos/defaultdebuggervisualizer.jpg I'd love to control what goes into the string currently displaying the type name, like a function or property that, if implemented, overrides the default debugger class type display. I.e. in the image above I'd want to replace the "{Ecommerce.Shoppingcart}" with the output of Ecommerce.Shoppingcart.ToString(). Any idea if and how this is possible? Thanks, Ingmar

      modified on Monday, November 10, 2008 3:00 PM

      J Offline
      J Offline
      Jon_Boy
      wrote on last edited by
      #2

      Couldn't you do items(0).tostring in the watch window? Or you could override the .tostring and loop the items with a debug.writeline with how you want the data formated.

      Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

      I 1 Reply Last reply
      0
      • I in9mar

        Hi, in the Visual Studio Debug View value column (same as the debug mode hover pop up tooltip) I find it inefficient that for variables of compound types only the type name is displayed and to get to any state information I need to expand the display (click on plus icon). I found an example image here: http://www.davidhayden.com/photos/defaultdebuggervisualizer.jpg I'd love to control what goes into the string currently displaying the type name, like a function or property that, if implemented, overrides the default debugger class type display. I.e. in the image above I'd want to replace the "{Ecommerce.Shoppingcart}" with the output of Ecommerce.Shoppingcart.ToString(). Any idea if and how this is possible? Thanks, Ingmar

        modified on Monday, November 10, 2008 3:00 PM

        S Offline
        S Offline
        Scott Dorman
        wrote on last edited by
        #3

        If you're using .NET 2.0 or later take a look at the DebuggerDisplay[^] attribute. Here are some additional resources as well: Using DebuggerDisplay Attribute[^] Enhancing Debugging with the Debugger Display Attributes[^]

        Scott Dorman

        Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


        Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

        I 1 Reply Last reply
        0
        • J Jon_Boy

          Couldn't you do items(0).tostring in the watch window? Or you could override the .tostring and loop the items with a debug.writeline with how you want the data formated.

          Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

          I Offline
          I Offline
          in9mar
          wrote on last edited by
          #4

          > Couldn't you do items(0).tostring in the watch window? > Or [...] override the .tostring and loop the items with a debug.writeline [...] Of course I could, but that is equally inefficient, i.e. I need to do stuff to get to the state information. What I want is to sit down once (per custom type), write a useful concise state to string conversion, and then have it be used automatically by Visual Studio whenever the matching variables are in a debug view.

          1 Reply Last reply
          0
          • S Scott Dorman

            If you're using .NET 2.0 or later take a look at the DebuggerDisplay[^] attribute. Here are some additional resources as well: Using DebuggerDisplay Attribute[^] Enhancing Debugging with the Debugger Display Attributes[^]

            Scott Dorman

            Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


            Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

            I Offline
            I Offline
            in9mar
            wrote on last edited by
            #5

            Thanks Scott, this gets pretty close. However, C# and VB seem to behave differently. The documentation talks by default about the C# solution and how ToString() can be used to fill the debugger value field. That is exactly what I wanted. But in Visual Studio 2005 and VB.NET ToString() is by default a function, and unfortunately < DebuggerDisplay("{ToString}") > is rejected. Only if I use a property does it work, so I have to make a DbgStr() property that calls ToString(), a little ugly but works.

            S 1 Reply Last reply
            0
            • I in9mar

              Thanks Scott, this gets pretty close. However, C# and VB seem to behave differently. The documentation talks by default about the C# solution and how ToString() can be used to fill the debugger value field. That is exactly what I wanted. But in Visual Studio 2005 and VB.NET ToString() is by default a function, and unfortunately < DebuggerDisplay("{ToString}") > is rejected. Only if I use a property does it work, so I have to make a DbgStr() property that calls ToString(), a little ugly but works.

              S Offline
              S Offline
              Scott Dorman
              wrote on last edited by
              #6

              Unless your ToString method contains complex logic and formatting rules, you could specify it directly in the attribute as <DebuggerDisplay("ProperyOne = {PropertyOne}, PropertyTwo = {PropertyTwo}")>. Also, try specifying it like this: <DebuggerDisplay("{ToString**()**}")>.

              Scott Dorman

              Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


              Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

              1 Reply Last reply
              0
              • I in9mar

                Hi, in the Visual Studio Debug View value column (same as the debug mode hover pop up tooltip) I find it inefficient that for variables of compound types only the type name is displayed and to get to any state information I need to expand the display (click on plus icon). I found an example image here: http://www.davidhayden.com/photos/defaultdebuggervisualizer.jpg I'd love to control what goes into the string currently displaying the type name, like a function or property that, if implemented, overrides the default debugger class type display. I.e. in the image above I'd want to replace the "{Ecommerce.Shoppingcart}" with the output of Ecommerce.Shoppingcart.ToString(). Any idea if and how this is possible? Thanks, Ingmar

                modified on Monday, November 10, 2008 3:00 PM

                K Offline
                K Offline
                kurt griffiths
                wrote on last edited by
                #7

                You will want to look into adding custom AutoExpand rules. A search for AutoExp.dat should get you the info you need. Note: On my system, AutoExp.data is located here: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Packages\Debugger

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups