JetBrains Rider 2026.1 Help

代码检查:冗余的 [AttributeUsage] 特性属性赋值

当所赋值是冗余时,此检查会报告 [AttributeUsage(...)] 内部的属性赋值。 这种情况发生在值本来就是默认值,或当像 Inherited 这样的属性对于选定的特性目标没有意义时。

示例

using System; [AttributeUsage(AttributeTargets.Method, Inherited = true)] sealed class MyAttribute : Attribute { }
using System; [AttributeUsage(AttributeTargets.Method)] sealed class MyAttribute : Attribute { }

快速修复

修复后,特性的行为保持不变,同时移除声明中的多余内容。

2026年 5月 8日