Table of Contents

Class MethodWrapper

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

The MethodWrapper class wraps a MethodInfo so that it may be used in a platform-independent manner.

public class MethodWrapper : IMethodInfo, IReflectionInfo, IEquatable<MethodWrapper>
Inheritance
MethodWrapper
Implements
Inherited Members

Constructors

MethodWrapper(Type, MethodInfo)

Construct a MethodWrapper for a Type and a MethodInfo.

public MethodWrapper(Type type, MethodInfo method)

Parameters

type Type
method MethodInfo

MethodWrapper(Type, string)

Construct a MethodInfo for a given Type and method name.

public MethodWrapper(Type type, string methodName)

Parameters

type Type
methodName string

Properties

ContainsGenericParameters

Gets a value indicating whether the method contains unassigned generic type parameters.

public bool ContainsGenericParameters { get; }

Property Value

bool

IsAbstract

Gets a value indicating whether the method is abstract.

public bool IsAbstract { get; }

Property Value

bool

IsGenericMethod

Gets a value indicating whether the method is a generic method.

public bool IsGenericMethod { get; }

Property Value

bool

IsGenericMethodDefinition

Gets a value indicating whether the MethodInfo represents the definition of a generic method.

public bool IsGenericMethodDefinition { get; }

Property Value

bool

IsPublic

Gets a value indicating whether the method is public.

public bool IsPublic { get; }

Property Value

bool

IsStatic

Gets a value indicating whether the method is static.

public bool IsStatic { get; }

Property Value

bool

MethodInfo

Gets the MethodInfo for this method.

public MethodInfo MethodInfo { get; }

Property Value

MethodInfo

Name

Gets the name of the method.

public string Name { get; }

Property Value

string

ReturnType

Gets the return Type of the method.

public ITypeInfo ReturnType { get; }

Property Value

ITypeInfo

TypeInfo

Gets the Type from which this method was reflected.

public ITypeInfo TypeInfo { get; }

Property Value

ITypeInfo

Methods

Equals(MethodWrapper?)

public bool Equals(MethodWrapper? other)

Parameters

other MethodWrapper

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetCustomAttributes<T>(bool)

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

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

Parameters

inherit bool

Returns

T[]

Type Parameters

T

GetGenericArguments()

Returns the Type arguments of a generic method or the Type parameters of a generic method definition.

public Type[] GetGenericArguments()

Returns

Type[]

GetHashCode()

public override int GetHashCode()

Returns

int

GetParameters()

Gets the parameters of the method.

public IParameterInfo[] GetParameters()

Returns

IParameterInfo[]

Invoke(object?, params object?[]?)

Invokes the method, converting any TargetInvocationException to an NUnitException.

public object? Invoke(object? fixture, params object?[]? args)

Parameters

fixture object

The object on which to invoke the method

args object[]

The argument list for the method

Returns

object

The return value from the invoked method

IsDefined<T>(bool)

Gets a value indicating whether one or more attributes of the specified type are defined on the method.

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

Parameters

inherit bool

Returns

bool

Type Parameters

T

MakeGenericMethod(params Type[])

Replaces the type parameters of the method with the array of types provided and returns a new IMethodInfo.

public IMethodInfo MakeGenericMethod(params Type[] typeArguments)

Parameters

typeArguments Type[]

The type arguments to be used

Returns

IMethodInfo

A new IMethodInfo with the type arguments replaced

ToString()

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

public override string ToString()

Returns

string