Table of Contents

Class ReflectionExtensions

Namespace
Xunit.Sdk
Assembly
xunit.v3.common.dll

Extension methods for reflection types in .NET.

public static class ReflectionExtensions
Inheritance
ReflectionExtensions
Inherited Members

Methods

GetDefaultValue(Type)

Returns the default value for the given type. For value types, this means a 0-initialized instance of the type; for reference types, this means null.

GetDisplayNameWithArguments(MethodInfo, string, object?[]?, Type[]?)

Formulates the extended portion of the display name for a test method. For tests with no arguments, this will return just the base name; for tests with arguments, attempts to format the arguments and appends the argument list to the test name.

GetMatchingCustomAttributes(Attribute, string)

Gets all the custom attributes for the attribute that are of the given attribute type.

GetMatchingCustomAttributes(Attribute, Type)

Gets all the custom attributes for the attribute that are of the given attribute type.

GetMatchingCustomAttributes(Assembly, string)

Gets all the custom attributes for the assembly that are of the given attribute type.

GetMatchingCustomAttributes(Assembly, Type)

Gets all the custom attributes for the assembly that are of the given attribute type.

GetMatchingCustomAttributes(MethodInfo, string)

Gets all the custom attributes for the method that are of the given attribute type.

GetMatchingCustomAttributes(MethodInfo, Type)

Gets all the custom attributes for the method that are of the given attribute type.

GetMatchingCustomAttributes(ParameterInfo, string)

Gets all the custom attributes for the parameter that are of the given attribute type.

GetMatchingCustomAttributes(ParameterInfo, Type)

Gets all the custom attributes for the parameter that are of the given attribute type.

GetMatchingCustomAttributes(Type, string)

Gets all the custom attributes for the type that are of the given attribute type.

GetMatchingCustomAttributes(Type, Type)

Gets all the custom attributes for the type that are of the given attribute type.

Implements(Type, Type)

Determines if the given type implements the given interface.

IsFromLocalAssembly(Type)

Determines if the given type is from a local assembly.

IsNullable(Type)

Determines whether type is a nullable type; that is, whether it is a reference type or it represents Nullable<T> for a value type.

IsNullableEnum(Type)

Determines whether type represents a nullable enum value.

ResolveGenericTypes(MethodInfo, object?[])

Resolves all the generic types for a test method. The arguments are used to determine the best matching generic types for the method that can be satisfied by all the generic parameters and their argument values.

ResolveMethodArguments(MethodBase, object?[])

Resolves argument values for the test method, ensuring they are the correct type, including support for optional method arguments.

SafeName(Type)

Gets a fully qualified type name (i.e., FullName), falling back to a simple type name (i.e., Name) when a fully qualified name is not available. Typically used when presenting type names to the user, or to guarantee the type name is never null.

ToCommaSeparatedList(IEnumerable<Type?>, string)

Convert a collection of Type objects into a comma-separated list for display purposes.

ToDisplayName(Type)

Converts a type into a name string for display purposes. It attempts to make a more user friendly name than FullName would give, especially when the type is generic.

ToSimpleName(Type)

Gets the simple name for a type, suitable for use with TestClassSimpleName.

ToVSTestTypeName(Type, MethodInfo?, Type?)

Converts a Type name into the correct form for VSTest managed type name for using in managed TestCase properties and by xunit.runner.visualstudio.

UnwrapNullable(Type)

Attempts to strip Nullable<T> from a type value and just return T. For non-nullable types, will return the type that was passed in.