Visual Studio: set change of variable value as a stopping criteria

I'm debugging quite a big code in VB and I'd find it really helpful if I could set a breakpoint not in particular place in code, but rather in form of a trigger for changing the value of certain variable in the following 'pythonic' manner:

Class debug_variable(String):
    __set__(value):
      self.value = value
      debugger.break 

do you know such feature in Visual Studio 2010?

Upvotes: 1

Views: 168

Answers (2)

Matt Wilko
Matt Wilko

Reputation: 27322

You can do something like this. It will break whenever the property is Set.

Public Class DebugVariable
    Private _value As String
    Public Property Value As String
        Get
            Return _value
        End Get
        Set(value As String)
            _value = value
            Debugger.Break()
        End Set
    End Property
End Class

Upvotes: 1

Obsidian Phoenix
Obsidian Phoenix

Reputation: 4155

You can set conditions on the Breakpoint, which allows you to break when the value changes, but unfortunately it only applies for native code (i.e. C++)

Breakpoints

One option you could do is to create the variable as a property with a backing variable and break on the set code. It's a bit clunky - especially if the variable is a method scope variable rather than class level, but it may serve as a workaround.

Upvotes: 0

Related Questions