-
Couldn't load subscription status.
- Fork 277
Closed
Description
NSubstitute/src/NSubstitute/Proxies/CastleDynamicProxy/CastleDynamicProxyFactory.cs
Line 167 in f890efa
| private static bool HasItems<T>(T[]? array) => array?.Length != 0; |
It was changed from:
private static bool HasItems<T>(T[]? array)
{
return array != null && array.Length > 0;
}to
private static bool HasItems<T>(T[]? array) => array?.Length != 0;Those two statements behave differently if array is null. The old code resulted in false but the new code returns true in this case. I don't think that was an intentional change?
Message:
NSubstitute.Exceptions.SubstituteException : Can not provide constructor arguments when substituting for an interface.
Stack Trace:
CastleDynamicProxyFactory.VerifyNoConstructorArgumentsGivenForInterface(Object[] constructorArguments)
CastleDynamicProxyFactory.CreateProxyUsingCastleProxyGenerator(Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments, IInterceptor[] interceptors, ProxyGenerationOptions proxyGenerationOptions)
CastleDynamicProxyFactory.GenerateTypeProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
CastleDynamicProxyFactory.GenerateProxy(ICallRouter callRouter, Type typeToProxy, Type[] additionalInterfaces, Object[] constructorArguments)
SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments, Boolean callBaseByDefault)
SubstituteFactory.Create(Type[] typesToProxy, Object[] constructorArguments)
Substitute.For(Type[] typesToProxy, Object[] constructorArguments)
Changing it to this should fix it:
private static bool HasItems<T>(T[]? array) => array?.Length > 0;Metadata
Metadata
Assignees
Labels
No labels