コードインスペクション:冗長な [AttributeUsage] 属性プロパティの割り当て
このインスペクションは、割り当てられた値が冗長な場合に、 [AttributeUsage(...)] 内のプロパティ割り当てを報告します。 これは、値がそもそもデフォルト値である場合、または Inherited などのプロパティが選択された属性ターゲットに対して意味をなさない場合に発生します。
サンプル
using System;
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
sealed class MyAttribute : Attribute
{
}
using System;
[AttributeUsage(AttributeTargets.Method)]
sealed class MyAttribute : Attribute
{
}
クイックフィックス
この修正により、属性の動作はそのまま維持されつつ、宣言から不要なノイズが削除されます。
2026 年 6 月 12 日