Debugging automatic properties

Marek Kwiendacz picture Marek Kwiendacz · Dec 10, 2010 · Viewed 23.7k times · Source

Is there any way to set breakpoint on setter/getter in auto-implemented property?

int Counter { get; set; }

Other than changing it to standard property (I'm doing it in this way, but to do that I have to change and recompile whole project)

Answer

Matt Smith picture Matt Smith · Jul 16, 2011

Using Visual Studio 2008, 2010, 2012, 2013:

  1. Go to the Breakpoint window
  2. New -> Break at Function…
  3. For the get, type: ClassName.get_Counter()

    For the set, type: ClassName.set_Counter(int)

You'll get a "No Source Available" when the breakpoint is hit, but you'll get the calling location in the call stack.

I found this solution here on MSDN