--
Post: moq...@googlegroups.com
Unsubscribe: moqdisc-u...@googlegroups.com
On 11 Mar, 19:39, Daniel Cazzulino <k...@clariusconsulting.net> wrote:
> mmm... interesting. not sure DynamicProxy allows this... Krzysztof?
>
> /kzu
>
> --
> Daniel Cazzulino | Developer Lead | XML MVP | Clarius Consulting | +1
> 425.329.3471
>
> On Tue, Mar 9, 2010 at 10:48, mcintyre321 <mcintyre...@gmail.com> wrote:
> > I was just reading
> >http://garmhold.blogspot.com/2010/03/relax-you-can-mostly-stop-using....
> > - it seems in Java you can create a mock without calling the base
> > class constructor - sounds good to me! Would it be possible to do this
> > in .NET using FormatterServices.Get(Safe)UninitializedObject method
> > (see
> >http://msdn.microsoft.com/en-us/library/system.runtime.serialization....
looks like it is not possible in .NET
On Mar 12, 9:19 am, Krzysztof Koźmic (2) <krzysz...@kozmic.pl> wrote:
> [IL]: Error: [D:\test\CastleDynProxy2.dll :
> Castle.Proxies.IServiceProxy::.ctor][mdToken=0x600000f][offset
> 0x0000000E] Return from .ctor when this is uninitialized.
>
> looks like it is not possible in .NET
>
However Moq could theoretically mock objects having no default .ctor
without having to do any changes in DP itself.
isntead of using proxyGenerator.CreateClassProxy, which rerurns proxy
instance, it could call proxyFactory.CreateClassProxyType which
returns type. It then could call
FormatterServices.Get(Safe)UninitializedObject, set all the fields via
Reflection and potentially be good to go.
This is a hack though, and I'm not sure it's such a good idea anyway.
TTBOMK Moq (same as Rhino.Mocks) allows you to call non-default .ctors
on your mocked class, so it's a pretty artificial issue anyway.
On 12 Mar, 10:30, mcintyre321 <mcintyre...@gmail.com> wrote:
> Dang. Thanks for taking a look though.
>