I suggest you ...

Support Data Breakpoints for C#

This suggestion is migrated to Developer Community. Please use below link to view the current status.
https://developercommunity.visualstudio.com/content/idea/351314/support-data-breakpoints-for-c.html
Data Breakpoints are very useful when debugging state issues as they break into the debugger when the value of a variable changes.

It is currently only supported in C/C++

Please extend support to C# and the other managed languages. We need it badly. The reason there is no uservoice suggestion is that most NET Developers don't know it exists in C++

758 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
Tom Pester shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

Hi Supporters of Data Breakpoints for C#!

I am currently looking into this suggestion to investigate what the possibilities for this could be. Please take this short survey (https://www.research.net/r/DataBreakpoints1) to help me know more specifically how C# Data Breakpoints will help you in your development process.

Looking forward to hearing from you,
Kaycee Anderson

26 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Anonymous commented  ·   ·  Flag as inappropriate

    Data breakpoints are useful in debugging memory leaks, array bound violations, and heisen-bugs (bugs which you know are there but are uncertain how to trigger them or are trigger with timing situations that vary, ie: exists in release but not debug because the timing is different). While these may not occur in c# as frequently I have seen them occur when integrating a library written in c/c++ or other language. It would be useful in at least determining where the bug is originating.

  • Gregg Hamilton commented  ·   ·  Flag as inappropriate

    I'm still new to C#, and may be stating the obvious here, but I found a solution that worked in my case. It won't help with breaking on read access but if something is changing a value and you want to know who, here is what I did. Consider a class foo with an int member variable that should stay the same for the life of the object.

    using System;
    using System.Threading;

    public class Watcher
    {
    public static void DoWatch(object data)
    {
    foo f = data as foo;

    while (true)
    {
    Thread.Sleep(0);
    if (f.val != f.initialVal)
    {
    System.Diagnostics.Debug.Assert(false);
    }
    }
    }

    public class foo
    {
    int val = 0;
    int initialVal = 0;
    Thread newThread = new Thread(Watcher.DoWatch);

    public foo(int v)
    {
    val = v;
    initialVal = v;
    newThread.Start(this);
    }
    }

    I put a breakpoint on the assert, and when I hit the breakpoint I was able to examine the other threads and see who was doing what. It's not precise, but it's close enough to give you an idea where to look for the offender.

  • Fedor Taiakine commented  ·   ·  Flag as inappropriate

    Need this feature badly... The Sitecore profile property changes randomly and there is no way to put breakpoint within... This feature used to work!

  • Joshua McAnaney commented  ·   ·  Flag as inappropriate

    I could really use this for the horror show of Unity, which has decided to remap my memory internally on several occasions. There's very little I can do as there is zero access to the addresses in question on the managed side, and it's overrunning in a way I can't even track down sensibly without data breakpoints.

  • f commented  ·   ·  Flag as inappropriate

    Yes please ! Badly needed. This is very helpful also when the code goes fubar and data gets trampled over! It has saved my skin more than once!

  • Alexander commented  ·   ·  Flag as inappropriate

    Here is one possible workaround:
    1. Find all references to the variable of interests
    2. Set breakpoints on all assignment statements

  • Ed commented  ·   ·  Flag as inappropriate

    Add this feature please! It would be very helpful to me today... but at least having it in a year would be good.

  • Anonymous commented  ·   ·  Flag as inappropriate

    I have been working for long year up to VS2010 and recently worked for a couple of years on Linux and I can't say how much I'm looking forward for the current Windows based project is finished and I'll be able to return. I have to work now with VS 2015. I found out that there is a bunch of new blinky features most of them unnecessary, but they have killed useful features like macros and data breakpoints?!??

    And for both those basic things developers have to beg to get them back? !?! Unbelievable...

  • Tom Pester commented  ·   ·  Flag as inappropriate

    @David That is a workaround I currently use and it works well. The only reason I can think if when this workaround fails is code that uses reflection and counts on the data being a field instead of a property. Still, modifying code to support debugging (which should be reverted afterwards) and stopping your debug flow each time is required is what makes it worth for me to be implemented. Once developers know it exists it can really help daily debugging and a certain class of bugs can be tracked in minutes instead of hours.

  • David commented  ·   ·  Flag as inappropriate

    While I agree this is a cool idea and I would probably use it at some point or another, I feel compelled to point out that simply using a "setter" and putting a breakpoint in there would accomplish the same thing (assumes you have control over the code you are trying to watch).

  • Anonymous commented  ·   ·  Flag as inappropriate

    It is absurd that something that has been in development packages since early foxpro has not been implement in VS 2013

  • Mehrad commented  ·   ·  Flag as inappropriate

    A friend of mine told me this is not available on C# and I was devastated. Would be great to have it.

  • David Dunetz commented  ·   ·  Flag as inappropriate

    This could be incorporated into the Watch window.

    Break when a value changes, or when a specific value is set.

    First assignment of a variable or field constitutes the initial value. Going out of scope, or first assignment in scope does not trigger a break.

← Previous 1

Feedback and Knowledge Base