Method CreateInstance
- Namespace
- Xunit.v3
- Assembly
- xunit.v3.core.dll
CreateInstance(ConstructorInfo, object?[]?, Func<Type, IReadOnlyCollection<ParameterInfo>, string>)
Creates an instance of the specified type using the constructor that best matches the specified parameters.
object CreateInstance(ConstructorInfo constructor, object?[]? arguments, Func<Type, IReadOnlyCollection<ParameterInfo>, string> missingArgumentMessageFormatter)
Parameters
constructorConstructorInfoThe constructor to be invoked.
argumentsobject[]An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
missingArgumentMessageFormatterFunc<Type, IReadOnlyCollection<ParameterInfo>, string>A function that will format the message to be used to throw an exception when one or more arguments could not be resolved.
Returns
- object
A reference to the newly created object.
Remarks
This method may called with parameter values that are set to Value. This indicates that the test framework does not know how to resolve the argument in question. Implementation for missing parameter resolution is an implementation detail for the type activator (throwing is an acceptable result).
Exceptions
Thrown when the object creation is not successful.