Sunday, November 23, 2008

Postsharp and sanity checks

While playing with Postsharp for a validation framework i stumbled upon this.
This is a great little code block that stops sneaky team members referencing layers they should not be referencing. a compile time error will ensue and let them know, for example, that they can not access the DAL via the View projects... happy days!

4 comments:

Lee Campbell said...

This would be a god-send at the last place I worked. Sometimes it felt like the lawless wild west where anything could reference anything (and generally everything!)

Davy Brion said...

one thing to keep in mind though is that this kind of stuff does slow down the compilation of the project.

If you're doing TDD, then this can become a bit of a pain when working on large solutions

RhysC said...

Thats true Davy, and post sharp is a signifiacnt delay in compilation. How this would be handled if it became a problem?
Possibly a local version of the assinfo.cs with the attribute, but thats pretty messy.
Possible use a debug block to comment it out, with the build server using a different build profile... hmm

Davy Brion said...

yeah, if you're using the technique just to make sure that nobody is using the wrong stuff in places where they shouldn't, it might be a good idea to just replace the assemblyinfo.cs file on the buildserver so the check only happens there