Skip to main content

Posts

Showing posts from 2012

Working with Stylecop

I was recently asked to review the use of Stylecop as part of our standard procedures for ASP.Net projects. I'd not used it before, but was fairly happy to consider doing so as code styling has always been one of my pedantic points when reviewing code (including my own!). Have to admit I was less keen once I'd installed it and found it complaining with around several hundred warnings - on a single, not that complex, and - I'd thought - beautifully coded class library. Having uninstalled it, calmed down a bit a couple of weeks later, reinstalled it, and put aside an afternoon to work through one particular solution... came to the conclusion it did have quite a lot of value. Although no individual change was of any great significance, the code certainly felt better once the refactoring effort had been completed - and we'd expect over time that any best practices it enforced we weren't adhering too, would become normal coding style. So our plan is to use it on...

Codegarden 2012 and Umbraco 5

Last week I attended Codegarden – the annual conference for the developers using the open source .Net CMS Umbraco held in Copenhagen. It’s probably fair to say that it’s not a typical technical conference. Rather more beer, bingo and unicyclists dressed as Darth Vadar playing the bagpipes than you might usually find. Those aspects weren’t completely unexpected though. It was our first time at the conference but we’d had prior notice of the Danish take on Monty Python surrealist humour found during some of the “extra-curricular” sessions. What was more of a surprise though was the announcement in the keynote – that they were scrapping development of the new version of Umbraco . I have been following the progress of version 5 quite closely – working with it with colleagues in test projects and making some small contributions to its development. Although after its release a few months ago some issues were becoming apparent from reports of those using it; to take a call to aban...

An Entity Framework Stale Data Gotcha

For ASP.Net MVC development I've been working for a while with a setup using Entity Framework Code First and Castle Windsor for providing IoC container services. I recently ran into a weird bug that may be obvious to some... but given I wasted an hour or so working it out figured it was worth a blog post. The issue was that for a certain operation I was getting stale data out of Entity Framework. With the help of the very useful Entity Framework Profiler which was reporting an ObjectContext being shared across threads I tracked it down to my implementation of a custom membership and role provider. For most use of the IoC container I have a custom controller factory, that handles resolving the dependent types. But there are some parts of the application that need access to classes managed through the container, but that aren't within the context of a controller. Custom membership and role providers are examples of these. With Castle Windsor (and other IoC container...