Tuesday, April 20, 2010

Disabling Moles Pre-Compilation

One thing about Moles that I've found a bit annoying is that the Mole types always get compiled into an assembly. This is fine when you mole something like mscorlib because it's not going to be changing, but when you mole your own code, the result is that you have a dependency on a binary file that keeps changing over and over. If you check your code into source control, this is a nuisance.

It turns out that if you open a .moles file and add <Compilation Disable="true"/>, Moles won't generate an assembly and will instead put the source directly into your test project. In my opinion, this is much cleaner. Now you don't have binary files to keep track of and fewer assembly references in your test project.


Anonymous said...

This could be useful to us. Where did you find this? I did a search in the included moles documentation and I didnt get any hits.

nw said...

I had asked a question about this on the Pex MSDN forum and Peli (one of the primary project owners) responded: http://social.msdn.microsoft.com/Forums/en-US/pex/thread/70530f9f-d119-4ad4-b8a5-910121b5a74e