Debugging automatic properties
Using Visual Studio 2008, 2010, 2012, 2013:
- Go to the Breakpoint window
- New -> Break at Function…
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:
- Go to the Breakpoint window
- New->Break at Function…
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
What's the Method Representation in Memory
Is There an Equivalent to the Scanner Class in C# for Strings
How to Read a .Net Guid into a Java Uuid
When Not to Use Regex in C# (Or Java, C++, etc.)
What Is the "Volatile" Keyword Used For
How Does Creating a Instance of Class Inside of the Class Itself Works
Posting JSON to Url via Webclient in C#
How to Lock a Table on Read, Using Entity Framework
How to Upload a File to an Sftp Server in C# (.Net)
How to Use the Cancellationtoken Property
ASP.NET Core 6 How to Access Configuration During Startup