You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
As soon as the readonly struct Path in the repro below has a call to another ctor the following AmbiguousArgumentsException is thrown:
NSubstitute.Exceptions.AmbiguousArgumentsExceptionHResult=0x80131500Message=Cannot determine argument specifications to use. Please use specifications for all arguments of the same type.
Method signature:
Do<Parent, Base, Child>(Path<Base,Parent>,Func<Parent,Base>)Method arguments (possiblearg matchers are indicated with '*'):Do<Parent,Base,Child>(NSubRepro.Path`2[NSubRepro.Base,NSubRepro.Parent],*<null>*)All queued specifications:
any Path<Base, Parent>
any Func<Parent, Child>
Matched argument specifications:
Do<Parent, Base, Child>(NSubRepro.Path`2[NSubRepro.Base,NSubRepro.Parent],???)Source=NSubstitute
StackTrace:
at NSubstitute.Core.Arguments.ArgumentSpecificationsFactory.Create(IList`1argumentSpecs,Object[]arguments,IParameterInfo[]parameterInfos,MethodInfomethodInfo,MatchArgsmatchArgs)
at NSubstitute.Core.CallSpecificationFactory.CreateFrom(ICallcall,MatchArgsmatchArgs)
at NSubstitute.Routing.Handlers.RecordCallSpecificationHandler.Handle(ICallcall)
at NSubstitute.Routing.Route.Handle(ICallcall)
at NSubstitute.Core.CallRouter.Route(ICallcall)
at NSubstitute.Proxies.CastleDynamicProxy.CastleForwardingInterceptor.Intercept(IInvocationinvocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at NSubstitute.Proxies.CastleDynamicProxy.ProxyIdInterceptor.Intercept(IInvocationinvocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.ObjectProxy.Do[TParent,TBaseChild,TChild](Path`2parentPath, Func`2relation)
at NSubRepro.Program.Main(String[]args)inD:\Repros\NSubRepro\NSubRepro\Program.cs:line 15
To Reproduce
Repro code:
usingSystem;usingSystem.Collections.Generic;usingSystem.Collections.Immutable;usingSystem.Threading.Tasks;usingNSubstitute;namespaceNSubRepro{internalclassProgram{staticvoidMain(string[]args){vartestMock=Substitute.For<ITest>();testMock.Do<Parent,Base,Child>(Arg.Any<Path<Base,Parent>>(),Arg.Any<Func<Parent,Child>>()).Returns(Task.CompletedTask);}}publicreadonlystructPath<TVisit,TMatch>{privatereadonlyImmutableList<TVisit>_nodes;// As soon as the call to the other ctor is commented out, it workspublicPath():this(ImmutableList<TVisit>.Empty){}privatePath(TVisitnode):this(ImmutableList<TVisit>.Empty.Add(node)){}privatePath(ImmutableList<TVisit>nodes){_nodes=nodes;}}publicinterfaceITest{TaskDo<TParent,TBaseChild,TChild>(Path<Base,TParent>parentPath,Func<TParent,TBaseChild>relation)whereTParent:BasewhereTBaseChild:BasewhereTChild:TBaseChild;}publicabstractclassBase;publicsealedclassParent:Base{publicList<Child>Children{get;}=[];}publicsealedclassChild:Base;}
As soon as the this call in the Path ctor is commented, the exception is gone. I'm not sure how that call is responsible for that exception.
Expected behaviour
No exception
Environment:
NSubstitute version: 5.3.0
NSubstitute.Analyzers version: Csharp 1.0.17
Platform: .NET 9, x64 Windows 11
The text was updated successfully, but these errors were encountered:
Describe the bug
As soon as the readonly struct
Path
in the repro below has a call to another ctor the followingAmbiguousArgumentsException
is thrown:To Reproduce
Repro code:
As soon as the
this
call in thePath
ctor is commented, the exception is gone. I'm not sure how that call is responsible for that exception.Expected behaviour
No exception
Environment:
The text was updated successfully, but these errors were encountered: