我正在尝试禁止特定属性的以下 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.");
}
}
}
我只是做错了什么吗?或者这是不可能的?这是一个很好的规则,只是对我的财产无效。
更新
尝试从 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.");
}
}
}