Debugging Automatic Properties

Debugging automatic properties

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

In VS2015, how do I disable Step Into for auto-implemented properties?

Go to the VS2015 options -> debugging -> general and tick "Step over properties and operators".

How to debug on a property's set in Visual studio 2010?

Use a full property rather than autoproperty.

The shortcut is propfull

private ISetting setting;

public ISetting Setting
{
get
{
return setting;
}
set
{
setting = value;
}
}

To use the code-snippet shortcut, type propfull and then press TAB twice.

Can't set breakpoints on an auto-property setter ? Why?

Using Visual Studio 2008, 2010, 2012:

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

    For the set, type: ClassName.set_CurrentFramesize(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: http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/b1dd0dc3-e9c1-402a-9c79-a5abf7f7286a

See also: Debugging automatic properties

Autoproperty debugging

1) the compiler don't save source code, it compiles. The implicit backing fields are only present in the IL code.

2) It's a feature, not a bug, I agree it could be great.

3) You have to create a backing field manually in order to put a breakpoint on it.

private string _prop;
public string Prop
{
get { return _prop; }
set { _prop= value; }
}

how to avoid triggering properties while debugging?

You can use the DebuggerBrowsableAttribute

DebuggerBrowsableAttribute Class



Related Topics



Leave a reply



Submit