简体   繁体   English

在调试器中跳过表达式实体属性

[英]Skip expression bodied property in debugger

Is there analog of [DebuggerStepThrough] attribute available for expression-bodied properties in C# ? C# 中是否有类似[DebuggerStepThrough]属性可用于表达式主体的属性?

For example I want to skip over the code例如我想跳过代码

public Byte ByteArray => Builder.CreateArray();

[DebuggerStepThrough] can not be applied to properties. [DebuggerStepThrough]不能应用于属性。 Does C# team provide any other solution in C# 6.0 ? C# 团队是否在 C# 6.0 中提供任何其他解决方案?

DebuggerStepThrough isn't valid for expression bodied properties as this: DebuggerStepThrough对表达式实体属性无效,因为:

[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.还有其他调试器属性,如DebuggerHiddenDebuggerNonUserCode ,但它们不会禁用步进。

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.您可以在调试选项中为所有属性禁用它,但 IMO 无法仅为表达式主体属性配置它。

C# 9.0: still no luck. C# 9.0:仍然没有运气。 An expression body can be used however:但是,可以使用表达式主体:

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

or the same code as one-liner:或与单行代码相同的代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM