Skip to content

Gendarme.Rules.BadPractice.DoNotUseEnumIsAssignableFromRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

DoNotUseEnumIsAssignableFromRule

Assembly: Gendarme.Rules.BadPractice
Version: git

Description

This rule checks for calls to typeof (Enum).IsAssignableFrom (type) that can be simplified to type.IsEnum.

Examples

Bad example:

if (typeof (Enum).IsAssignableFrom (type))  {
    // then the type is an enum
}

Good example:

if (type.IsEnum) {
    // then the type is an enum.
}

Notes

  • This rule is available since Gendarme 2.6

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally