c# - Castle ComponentRegistration error following upgrade to v3.0.0 -


i have inherited code base makes use of castle windsor ioc container, have been forced upgrade version v2.5.2 3.0.0 due compatibility issue.

following upgrade v3.0.0, following extension method in 1 of our test classes fails build following error:

the type 'tinterface' must reference type in order use parameter 'tservice' in generic type or method 'castle.microkernel.registration.componentregistration'

public static class containerextensions { /// <summary> /// sets registration expectation on mocked container. /// </summary> /// <typeparam name="tinterface">the type of interface.</typeparam> /// <typeparam name="timplementation">the type of implementation.</typeparam> /// <param name="container">the container.</param> public static void setregistrationexpectation<tinterface, timplementation>(this iwindsorcontainer container) timplementation : tinterface { predicate<ienumerable<iregistration>> pred = regs => { var reg = regs.oftype<componentregistration<tinterface>>().firstordefault(); return reg != null && reg.implementation == typeof(timplementation); }; container .expect(c => c.register(null)) .ignorearguments() .constraints(rhino.mocks.constraints.is.matching(pred)) .repeat.once(); } } 

so seem componentregistration can no longer take interface? having looked @ documentation still unsure how rectify?

any pointers appreciated.

try add where tinterface : class constraint method:

public static void setregistrationexpectation<tinterface, timplementation>(this iwindsorcontainer container) tinterface : class timplementation : tinterface 

it seems componentregistration generic constraints changed in 3.0.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -