Monday, 27 August 2012

OS X - Running StyleCop in MonoDevelop on C# code

When developing on Windows I find StyleCop to be a really useful tool for keeping code consistent throughout projects and I sorely miss it when developing C# projects on OS X with MonoDevelop.

I knew about a StyleCop addin for MonoDevelop here but at the time of writing it's not compatible with the latest version of MonoDevelop (3.0.3.5).

Time to get my hands dirty then! I forked the project on GitHub and modified it so that it works with MonoDevelop 3.0.3.5, the repository is here.

Upgrading the project was relatively easy, just tweaking a few version numbers in the addin manifest and reset the references. I also adjusted the StyleCop violations to output as Warnings rather that Errors, this suited the way I like to see the violations.

Getting the addin to run is another matter though - StyleCop uses the registry. Mono has a registry implementation but I found there were security issues involved with non admin processed reading and writing to it so in order to install the addin a little tweak to the registry permissions was required:

Navigate to the registry file:

On my machine it was here:

/Library/Frameworks/Mono.framework/Versions/2.10.9/etc/mono/registry/

Then adjust the security:

sudo chmod 777 last-btime

Here is a screen shot of it running:




Download and build from here:

https://github.com/mattlaver/Stylecop-Monodevelop-Addin