属性
值
规则 ID
IDE0076
标题
删除无效的全局 SuppressMessageAttribute
类别
CodeQuality
Subcategory
杂项规则
适用的语言
C# 和 Visual Basic
概述
此规则标记具有无效 Scope 或 Target 的全局 SuppressMessageAttributes。 应删除此属性或对其进行修补,以引用有效的作用域和目标符号。 此规则没有关联的代码样式选项。
示例
// IDE0076: Invalid target '~F:N.C.F2' - no matching field named 'F2'
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Category", "Id: Title", Scope = "member", Target = "~F:N.C.F2")]
// IDE0076: Invalid scope 'property'
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Category", "Id: Title", Scope = "property", Target = "~P:N.C.P")]
// Fixed code
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Category", "Id: Title", Scope = "member", Target = "~F:N.C.F")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Category", "Id: Title", Scope = "member", Target = "~P:N.C.P")]
namespace N
{
class C
{
public int F;
public int P { get; }
}
}
另请参阅
全局 SuppressMessageAttribute
避免在全局 SuppressMessageAttribute 中使用旧格式目标 (IDE0077)
代码样式规则参考
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有