Public Virtual Auto-Properties and CodeRush
Since starting to make the move towards utilizing NHibernate in most of my projects I have been a little frustrated by the need to make properties virtual. This is by no means a criticism of NHibernate just the tooling, specifically Visual Studio 2010 and CodeRush. Whilst CodeRush has templates for everything the virtual keyword dosn’t seem to get a look in, fortunately it’s not hard to add support. Thanks to Rory Becker’s article on Creating Virtual Methods I had everything I needed to create the template. Auto-properties are actually significantly less complex than methods as they are composed of little more than the type, property name and the { get; set; } block. Templates are easy enough to create from the DevExpress Options Menu (DevExpress Menu -> Options) you jump to the templates page quickly with the search in the top left hand corner. I prefer to organize my custom templates into their own folder, then I can easily import and export these between machines via drop box. 1) Right click your preferred folder and select “New Template” inter “u?Type?” and press enter/OK. 2) Set the Context - I copied the context of my template from a?Type? and removed the InStruct directive, as virtual is not valid in structures, the Use: field should read something like this: ...