Table of Contents

Class TypeWrapper

Namespace
NUnit.Framework.Internal
Assembly
nunit.framework.dll

The TypeWrapper class wraps a Type so it may be used in a platform-independent manner.

public class TypeWrapper : ITypeInfo, IReflectionInfo
Inheritance
TypeWrapper
Implements
Inherited Members

Constructors

TypeWrapper(Type)

Construct a TypeWrapper for a specified Type.

public TypeWrapper(Type type)

Parameters

type Type

Properties

Assembly

Gets the assembly in which the type is declared

public Assembly Assembly { get; }

Property Value

Assembly

BaseType

Gets the base type of this type as an ITypeInfo

public ITypeInfo? BaseType { get; }

Property Value

ITypeInfo

ContainsGenericParameters

Gets a value indicating whether the Type has generic parameters that have not been replaced by specific Types.

public bool ContainsGenericParameters { get; }

Property Value

bool

FullName

Gets the FullName of the Type

public string FullName { get; }

Property Value

string

IsAbstract

Gets a value indicating whether the type is abstract.

public bool IsAbstract { get; }

Property Value

bool

IsGenericType

Gets a value indicating whether the Type is a generic Type

public bool IsGenericType { get; }

Property Value

bool

IsGenericTypeDefinition

Gets a value indicating whether the Type is a generic Type definition

public bool IsGenericTypeDefinition { get; }

Property Value

bool

IsSealed

Gets a value indicating whether the type is sealed.

public bool IsSealed { get; }

Property Value

bool

IsStaticClass

Gets a value indicating whether this type represents a static class.

public bool IsStaticClass { get; }

Property Value

bool

Name

Gets the Name of the Type

public string Name { get; }

Property Value

string

Namespace

Gets the namespace of the Type

public string? Namespace { get; }

Property Value

string

Type

Gets the underlying Type on which this TypeWrapper is based.

public Type Type { get; }

Property Value

Type

Methods

Construct(object?[]?)

Construct an object of this Type, using the specified arguments.

public object Construct(object?[]? args)

Parameters

args object[]

Returns

object

GetConstructor(Type[])

Gets the public constructor taking the specified argument Types

public ConstructorInfo? GetConstructor(Type[] argTypes)

Parameters

argTypes Type[]

Returns

ConstructorInfo

GetCustomAttributes<T>(bool)

Returns an array of custom attributes of the specified type applied to this type

public T[] GetCustomAttributes<T>(bool inherit) where T : class

Parameters

inherit bool

Returns

T[]

Type Parameters

T

GetDisplayName()

Get the display name for this type

public string GetDisplayName()

Returns

string

GetDisplayName(object?[]?)

Get the display name for an object of this type, constructed with the specified args.

public string GetDisplayName(object?[]? args)

Parameters

args object[]

Returns

string

GetGenericTypeDefinition()

Returns a Type representing a generic type definition from which this Type can be constructed.

public Type GetGenericTypeDefinition()

Returns

Type

GetMethods(BindingFlags)

Returns an array of IMethodInfos for methods of this Type that match the specified flags.

public IMethodInfo[] GetMethods(BindingFlags flags)

Parameters

flags BindingFlags

Returns

IMethodInfo[]

GetMethodsWithAttribute<T>(bool)

Returns all methods declared by this type that have the specified attribute, optionally including base classes. Methods from a base class are always returned before methods from a class that inherits from it.

public IMethodInfo[] GetMethodsWithAttribute<T>(bool inherit) where T : class

Parameters

inherit bool

Specifies whether to search the fixture type inheritance chain.

Returns

IMethodInfo[]

Type Parameters

T

HasConstructor(Type[])

Returns a value indicating whether this Type has a public constructor taking the specified argument Types.

public bool HasConstructor(Type[] argTypes)

Parameters

argTypes Type[]

Returns

bool

HasMethodWithAttribute(Type)

Returns a flag indicating whether this type has a method with an attribute of the specified type.

public bool HasMethodWithAttribute(Type attributeType)

Parameters

attributeType Type

Returns

bool

IsDefined<T>(bool)

Returns a value indicating whether the type has an attribute of the specified type.

public bool IsDefined<T>(bool inherit) where T : class

Parameters

inherit bool

Returns

bool

Type Parameters

T

IsType(Type)

Returns true if the Type wrapped is T

public bool IsType(Type type)

Parameters

type Type

Returns

bool

MakeGenericType(Type[])

Returns a new ITypeInfo representing an instance of this generic Type using the supplied Type arguments

public ITypeInfo MakeGenericType(Type[] typeArgs)

Parameters

typeArgs Type[]

Returns

ITypeInfo

ToString()

Override ToString() so that error messages in NUnit's own tests make sense

public override string ToString()

Returns

string