container icon indicating copy to clipboard operation
container copied to clipboard

GenericResolvedArrayParameter throws ArgumentNullException exception if type does not match

Open ENikS opened this issue 6 years ago • 0 comments

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.

ENikS avatar May 30 '20 20:05 ENikS