gpt4 book ai didi

c# - 试图抑制 StyleCop 消息 SA1513 :ClosingCurlyBracketMustBeFollowedByBlankLine

转载 作者:太空狗 更新时间:2023-10-29 22:29:06 26 4
gpt4 key购买 nike

我正在尝试抑制特定属性的以下 StyleCop 消息:

SA1513: Statements or elements wrapped in curly brackets must be followed by a blank line.

我正在尝试执行以下操作,但它似乎不起作用:

    [SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")]
public string CustomerId
{
get
{
return this.GetProperty(CustomerIdProperty);
}
set
{
if (this.IsNew)
{
this.SetProperty(CustomerIdProperty, value);
}
else
{
throw new ReadOnlyException("Id value can only be changed for a new record.");
}
}
}

我是不是做错了什么?或者这是不可能的?这是一个很好的规则,只是对我的属性(property)无效。

更新

尝试从 DocumentationRules 切换到 LayoutRules ... 仍然没有抑制。

    [DataObjectField(true, false)]
[SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")]
public string CustomerId
{
get
{
return this.GetProperty(CustomerIdProperty);
}
set
{
if (this.IsNew)
{
this.SetProperty(CustomerIdProperty, value);
}
else
{
throw new ReadOnlyException("Id value can only be changed for a new record.");
}
}
}

最佳答案

我认为这可能是 StyleCop 的问题。你安装的是哪个版本? This page指出:

Starting with StyleCop 4.3.2, it is possible to suppress the reporting of rule violations by adding suppression attributes within the source code.

我刚刚发现我无法隐藏任何消息。我使用的安装程序只给出了 4.3 版本。最新版本在Codeplex是 4.4.0.0。确保安装了该版本。

更新

我一直在做一些检查,我可以抑制 DocumentationRules:

    [SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules",
"SA1600:ElementsMustBeDocumented",
Justification = "Reviewed. Suppression is OK here.")]

但不是 SpacingRules 或 LayoutRules。但是,我发现的任何内容都无法说明为什么会出现这种情况。

关于c# - 试图抑制 StyleCop 消息 SA1513 :ClosingCurlyBracketMustBeFollowedByBlankLine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2613892/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com