Class MethodWrapper
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
Typemethod
MethodInfo
MethodWrapper(Type, string)
Construct a MethodInfo for a given Type and method name.
public MethodWrapper(Type type, string methodName)
Parameters
Properties
ContainsGenericParameters
Gets a value indicating whether the method contains unassigned generic type parameters.
public bool ContainsGenericParameters { get; }
Property Value
IsAbstract
Gets a value indicating whether the method is abstract.
public bool IsAbstract { get; }
Property Value
IsGenericMethod
Gets a value indicating whether the method is a generic method.
public bool IsGenericMethod { get; }
Property Value
IsGenericMethodDefinition
Gets a value indicating whether the MethodInfo represents the definition of a generic method.
public bool IsGenericMethodDefinition { get; }
Property Value
IsPublic
Gets a value indicating whether the method is public.
public bool IsPublic { get; }
Property Value
IsStatic
Gets a value indicating whether the method is static.
public bool IsStatic { get; }
Property Value
MethodInfo
Gets the MethodInfo for this method.
public MethodInfo MethodInfo { get; }
Property Value
Name
Gets the name of the method.
public string Name { get; }
Property Value
ReturnType
Gets the return Type of the method.
public ITypeInfo ReturnType { get; }
Property Value
TypeInfo
Gets the Type from which this method was reflected.
public ITypeInfo TypeInfo { get; }
Property Value
Methods
Equals(MethodWrapper?)
public bool Equals(MethodWrapper? other)
Parameters
other
MethodWrapper
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
Returns
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
GetParameters()
Gets the parameters of the method.
public IParameterInfo[] GetParameters()
Returns
Invoke(object?, params object?[]?)
Invokes the method, converting any TargetInvocationException to an NUnitException.
public object? Invoke(object? fixture, params object?[]? args)
Parameters
fixture
objectThe 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
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()