Troubleshooting properties

I recently had an issue where I had updated configuration values, but I was not seeing the changes implemented in the user interface.
I opened the code and navigated to the screen where the values were being manipulated. Running debug showed me that the specific properties exited the method with the right values, but then were updated after I hit continue.

This is where we scratch our head.

Instead of digging through the code in a desperate search, I decided to focus on the property itself.

For example, let’s say the property is called StartDate. It is defined as below

[CSHARP]
public DateTime? StartDate { get; set; }
[/CSHARP]

With this set up, you won’t be able to use a breakpoint to track the value. So instead, expand it out to the following

[CSHARP]
private DateTime? startDate;

public DateTime? StartDate
{
get
{
return startDate;
}
set
{
startDate = value;
}
}
[/CSHARP]

Now you can put a breakpoint on the setter. Hit continue and catch it when it changes OUTSIDE of your expected scope.
Then you just need to check the Call Stack to see what is modifying the property.

Done deal!

Subscribe

0 comments