Solution to Ayende’s Challenge
I have always wanted to solve this puzzle Ayende posted on his blog, but haven’t got around it until today. It was a really hard puzzle, but with a little hint from Marc Gravell in the comments I was able to find a solution strategy based on .NET Remoting. Because Ayende’s original challenge was quite a bit harder (and actually impossible to solve, I wish I knew before) I tried messing with the typeof/new operators first. Sadly this isn’t possible and modifying any IL wasn’t allowed. On the other hand I learned a lot about the CLRs type system.
.NET Remoting is really interesting stuff, but to be honest I wouldn’t want to deal with it’s huge complexity in my every day job. I am not really sure which blank it fills in, besides interacting with ugly COM servers. If I compare all this stuff to Objective-C, I do now know about the benefits of late-bound, message-passing style function calls. Solving this challenge in Objective-C would have been substantially easier (a simple NSProxy plus Method Swizzling, just what OCMock does).
Anyway, you can find my solution on github.