Visualstudio-docs: Mention that a breakpoint cannot be set on a declaration.

Created on 28 Jun 2020  Â·  6Comments  Â·  Source: MicrosoftDocs/visualstudio-docs

[Enter feedback here]
I received a notice from someone taking one of my courses that they could not set a breakpoint on this line of code:

public event EventHandler EnrollmentFull;

I explained that one cannot set a breakpoint on a declaration unless it's being assigned a value or has a getter/setters. I then went to this documentation to provide a reference to back up my statement, and was unable to find any information on this important point.

The docs say this:

"You can't set a breakpoint on the namespace or class declarations, or on the method signature."

Please consider adding variable declarations to this list.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 doc-bug visual-studio-windowprod vs-ide-debutech

All 6 comments

@DeborahK Thanks for the feedback. I'll plan to update the doc.

Updating doc. Fix should be live around 5 PM.

Was hoping for a bit more ... especially now reading this first paragraph:

You can set a breakpoint on any line of executable code. For example, in the following C# code, you could set a breakpoint on the variable declaration, the for loop, or any code inside the for loop. You can't set a breakpoint on declarations for a namespace, class, or variable, or on the method signature.

So we first say: you could set a breakpoint on the variable declaration

Then say: You can't set a breakpoint on declarations for a namespace, class, or variable

If I were a beginner, I would be very confused by that!

Would it be possible to elaborate? And say when we can and when we cannot set a break point on a variable declaration?

Thank you!

You're right. I missed that first sentence. I'll look at this a bit closer.

I checked this. In the example, you can set the breakpoint because there's an assignment, so the line executes (you can pause on it while running code). You can't set a breakpoint on a variable declaration if there's no assignment. I'll edit this.

Updating. It should be live around 5 PM. Added the getter/setter info, too.

Was this page helpful?
0 / 5 - 0 ratings