3

I know that you can either step into every property or not step into every property, but I would really like to be able to step into a specific property, and not the rest. Is this possible? (I also know I can use keyboard commands, but I'm asking if there's a more permanent solution.) I have a lot of properties and my setters do important things, so it's silly to step over them, but most of my getters are pointless. I'm looking for something like:

public string ImportantProperty
{
    get { return _importantProperty; }
    [DebuggerStepThrough(false)]
    set
    {
        if (this.State != ConnectionState.Closed)
            throw new InvalidOperationException(
                "Important Property cannot be changed unless This is closed.");
        if (ImportantProperty == value)
            return;
        _importantProperty = value;
        OnImportantPropertyChanged(new EventArgs());
    }
}

Unfortunately, I can't find anything that will act like [DebuggerStepThrough(false)] and I must resort to turning off property step-over and putting [DebuggerStepThrough] everywhere I don't want to step-through.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
dlras2
  • 8,416
  • 7
  • 51
  • 90
  • 1. Interesting question. I would probably ask John Robbins for a solution. 2. Instead of new EventArgs() it is better to use EventArgs.Empty. – Ikaso May 25 '10 at 19:23
  • Also, check if anyone subscribes for the event before raising it, otherwise an exception will be thrown. That is: if(OnImportantPropertyChanged != null) OnImportantPropertyChanged(EventArgs.Empty); – Sameh Deabes May 25 '10 at 19:51

2 Answers2

2

Microsoft has information published for how to do this in Visual Studio 2010 and 2008. These techniques work fine in Visual Studio 2012.

How to: Step Into Properties and Operators in Managed Code

Read through all of the steps if you want, or just edit the Tools > Options using the screen capture below (check or uncheck that one item):

screenshot

Where is this useful?

If you uncheck the item Step over properties and operators (Managed only), then F11 will step into a property or method. F10 will step over it.

1

Why don't you put breakpoints in properties' setters of interest only and press F5 to run till the next breakpoint?

Why don't you step-over unimportant properties -at setting them- by pressing shift+F11?

Sameh Deabes
  • 2,960
  • 25
  • 30