Skip to main content

Posts

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...

Umbraco 5 Surface Controller

In a recent post I blogged my first steps in creating plugins for Umbraco 5 - creating a tree and editor using a custom hive provider for a third party database, in order to present and edit information within the Umbraco back office. I noted how the information could also be made available on the front-end of the site by writing code within the razor view template. Whilst that worked, it wasn't very satisfactory and certainly wasn't the MVC way with too much code and logic in the view. Since then the project has moved on and details have been made available for working with surface controllers . They can be created both directly within the Umbraco project in VS.Net or as plugins. Creating a Surface Controller To create a surface controller for use in a plug-in you create a class within a project with a reference to System.Web.Mvc and Umbraco.CMS.Web , with the following setup: Inherits from SurfaceController Named with a suffix of "SurfaceController" Has a class ...

Creating an Umbraco 5 Hive Provider with Custom Tree and Editor Plugin

Having used Umbraco CMS on a couple of projects in the past and been very impressed with it, I’ve been keen to follow progress on version 5 (or “Jupiter”) – a rewrite of the code-base to use ASP.Net MVC . In particular I’ve been looking recently at some of the extension points of the platform. One of these is building upon the data access abstraction layer that is being developed for Umbraco 5 – known as Hive . Umbraco itself will use NHibernate for data access, but via the Hive abstraction. The idea is that this default data access method could be swapped out – but perhaps more importantly by building a hive provider developers can expose other data sources to their Umbraco templates and back office. The back-office itself is also very pluggable, with the various node trees and editor interfaces also being extendable with your own custom implementations. In light of this I’ve been looking at a small project to create a hive provider for a custom database , along with a custom tr...