Skip expression bodied property in debugger

2019-06-27 17:16发布

问题:

Is there analog of [DebuggerStepThrough] attribute available for expression-bodied properties in C# ?

For example I want to skip over the code

public Byte ByteArray => Builder.CreateArray();

[DebuggerStepThrough] can not be applied to properties. Does C# team provide any other solution in C# 6.0 ?

回答1:

DebuggerStepThrough isn't valid for expression bodied properties as this:

[DebuggerStepThrough]
public Byte ByteArray => Builder.CreateArray();

Doesn't compile. This however does:

public Byte ByteArray
{
    [DebuggerStepThrough]
    get
    {
        return Builder.CreateArray();
    }
}

There are other debugger attributes like DebuggerHidden and DebuggerNonUserCode, but they don't disable step-through.

You can disable it for all properties in the debugging options, but there's no way IMO to configure it only for expression-bodied properties.



标签: c# c#-6.0