C#


ROSLYN.USAGE.CA2248 : Provide correct 'enum' argument to 'Enum.HasFlag' (C#)

See Roslyn-Detected C# Warning Classes for more information.

要旨

'Enum.HasFlag' method expects the 'enum' argument to be of the same 'enum' type as the instance on which the method is invoked and that this 'enum' is marked with 'System.FlagsAttribute'. If these are different 'enum' types, an unhandled exception will be thrown at runtime. If the 'enum' type is not marked with 'System.FlagsAttribute' the call will always return 'false' at runtime.

この指摘はRoslynのCA2248に該当します。ルール詳細につい ては、下記リンクを参照してください。 CA2248

プロパティ

クラス名 Provide correct 'enum' argument to 'Enum.HasFlag' (C#)
日本語クラス名 Provide correct 'enum' argument to 'Enum.HasFlag' (C#)
クラス分類 信頼性 (reliability)
ニーモニック ROSLYN.USAGE.CA2248
カテゴリー なし
対応言語 C# で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Provide correct 'enum' argument to 'Enum.HasFlag' (C#)"

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。