An NH Prof Bug Story: Why integration is tricky
Today I found out that NH Prof doesn't work with ASP.Net MVC applications. If you would have asked me, I would have sworn any oath you care to name that it would. And even after seeing the problem with my own eyes, it too me a while to track it down.
To make a long story short. Somewhere deep in the bowels of NH Prof, I made the assumption that a method is always contained in a type. I am pretty familiar with the way that the CLR works, and it seemed like a pretty reasonable assumption to make. In fact, I didn't even realize that I was making it.
Enter the ASP.Net MVC code, which generate method on the flies in order to do some of its work (haven't dug in, but I am willing to be that this is done using Expression.Compile() ). Methods that are generated on the fly using LCG do not have to be in a type. They can be just free floating methods. When my code encountered that, it choked and died horribly. Leading to a "there is no way this is happening" session.
The bug is fixed now, of course, but it is a good story, and a cautionary one about assumptions that you are not even aware that you are making.
Comments
my mantra: if u make an assumption then make an assumption about nothing.
Just noticed your blog doesn't have a search feature. With over 3,000 posts , it may be handy....
@Damien
you can use google:
www.google.com/search
I am with Damien here, its a nifty and a must-have feature. Few days back, I had to google for some (previous) posts, while reading another post, but if search was supported here, my task would be all the more simple.
Ayende, there is one more feature missing on your blog - the Home link takes me to your blog, there should be some link that takes me to your site ayende.com too. Please consider having them.
Thanks,
Manoj.
my mantra: make as many assumptions as possible,
as long that for each there is some proper Debug.Assert(...)
I suppose in your case, a simple
Debug.Assert(method.DeclaringType != null);
or so depending on the DOM you are using
would have pinpoint immediately the problem.
Another important things, make your Debug.Assert(...) active during tests as I described here:
codebetter.com/.../unit-test-vs-debug-assert.aspx
Comment preview