Table of Contents

Class TypeExtensions

Namespace
Badeend.EnumClass.Reflection
Assembly
Badeend.EnumClass.Reflection.dll

Utilities for inspecting enum class types at runtime.

public static class TypeExtensions
Inheritance
TypeExtensions
Inherited Members

Remarks

These methods assume that when a type has been marked as [EnumClass], it fully satisfies all the requirements that are normally checked by the analyzers in the primary nuget package. Usage of the [EnumClass] attribute without running the analyzers is not supported and might trigger undefined behavior.

Methods

GetDeclaringEnumClass(Type)

Returns the enum class this case is part of.

Returns null if the provided caseType is not part of any enum class.

public static Type? GetDeclaringEnumClass(this Type caseType)

Parameters

caseType Type

Returns

Type

GetEnumClassCases(Type)

Get the types of all the cases in no particular order.

Returns an empty array if enumType is not an enum class.

public static Type[] GetEnumClassCases(this Type enumType)

Parameters

enumType Type

Returns

Type[]

IsEnumClass(Type)

Check to see if the specified type is an "enum class".

Only the provided type itself is checked, it does not search up the inheritance chain.

public static bool IsEnumClass(this Type type)

Parameters

type Type

Returns

bool

IsEnumClassCase(Type)

Check to see if the specified type is a "case" within an enum class.

Only the provided type itself is checked, it does not search up the inheritance chain.

public static bool IsEnumClassCase(this Type type)

Parameters

type Type

Returns

bool