Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DebuggerStepThrough attribute equivalent for properties?

The DebuggerStepThrough attribute instructs the VS debugger to step through code instead of stepping into the code.

DebuggerStepThroughAttribute Class

My question is, is there an equivalent of this attribute to use it for a Property member?, because the setter of my property can throw an exception, and I don't want to break in the setter's code-block when that happens.

I know one solution is to move the setter's code to a single method and then set the DebuggerStepThrough attribute to that method, but I'm just asking for a possible alternative applying another attribute instead of moving code.

like image 992
ElektroStudios Avatar asked Jun 24 '15 16:06

ElektroStudios


1 Answers

You can actually apply this attribute directly to the getter and setter.

Dim firstName, lastName As String 
Property fullName() As String 
    <DebuggerStepThrough>
    Get 
      If lastName = "" Then 
          Return firstName
      Else 
          Return firstName & " " & lastName
      End If 

    End Get 

    <DebuggerStepThrough>
    Set(ByVal Value As String)
        Dim space As Integer = Value.IndexOf(" ")
        If space < 0 Then
            firstName = Value
            lastName = "" 
        Else
            firstName = Value.Substring(0, space)
            lastName = Value.Substring(space + 1)
        End If 
    End Set 
End Property

This is the same for C#.

like image 145
Mike Hofer Avatar answered Sep 26 '22 14:09

Mike Hofer