container
container copied to clipboard
GenericResolvedArrayParameter throws ArgumentNullException exception if type does not match
Description
The parameter operates normally when type is an array TestMethod(T[] array) but fails if it is something else TestMethod(object array).
It throws ArgumentNullException exception without any explanation or context to help diagnose the problem.
To Reproduce
[TestMethod]
public void GenericArrayTest()
{
// Arrange
var factory = new GenericResolvedArrayParameter("T[]");
ParameterInfo info =
typeof(TestClass<string>).GetMethod(nameof(TestClass<string>.TestMethod))
.GetParameters()
.First();
// Act
_ = factory.GetResolver<IResolveContext>(info);
}
Solution
GenericResolvedArrayParameter should throw InvalidOperationException with better explanation.