• Building Rhino Tools from the trunk

    I read about the release of Binsor 2.0, and thought that might be really handy for a current project. The problem is that you need to compile it yourself.

    This was causing me a few headaches and one late night after a countless false starts I gave up and posted to the Rhino Tools Dev group.

    Prerequisites

    You will need the command-line SVN tools (even if you already have TortoiseSVN).

    Directory layout

    I’ve used the following directory layout (with SVN repository paths):

    I then saved RhinoTools-Trunk\BuildFromTrunk-Config.build.sample to BuildFromTrunk-Config.build and edited it like this:

    <?xml version=“1.0” encoding=“utf-8”?>

    <Project DefaultTargets=“Update-All;Build-All;Copy-To-Artifact-Dir” xmlns=“http://schemas.microsoft.com/developer/msbuild/2003”>

    <PropertyGroup>

    <Configuration>debug</Configuration>

    <Enable-Tests>false</Enable-Tests>

    <Dest-Dir></Dest-Dir>

    <Dest-Lib-Dir>$(Dest-Dir)\lib\$(Configuration)</Dest-Lib-Dir>

    <Dest-Tool-Dir>$(Dest-Dir)\tools</Dest-Tool-Dir>

    <Tools-Dir>$(MSBuildProjectDirectory)\SharedLibs\Tools</Tools-Dir>

    <NH-Dir>$(MSBuildProjectDirectory)\..\NHibernate-Trunk\nhibernate</NH-Dir>

    <Castle-Dir>$(MSBuildProjectDirectory)\..\Castle-Trunk</Castle-Dir>

    <Rhino-Dir>$(MSBuildProjectDirectory)</Rhino-Dir>

    <Artifact-Dir>$(MSBuildProjectDirectory)\Trunk-Artifacts</Artifact-Dir>

    <MSBuildCommunityTasksPath>$(Tools-Dir)</MSBuildCommunityTasksPath>

    <Svn-Dir>$(Tools-Dir)\Subversion</Svn-Dir>

    </PropertyGroup>

    </Project>

    The final thing that caused me grief was some missing edits to RhinoTools-Trunk\rhino-commons\Rhino.Commons\Rhino.Commons.csproj. Hopefully this will be patched soon, but I had to make the following hand-edits to the csproj file:

    Index: Rhino.Commons.csproj =================================================================== — Rhino.Commons.csproj (revision 908) +++ Rhino.Commons.csproj (working copy) @@ -158,7 +158,9 @@ - + + +

    I then opened a Visual Studio 2005 Command Prompt (“Run as Administrator” on Vista), and entered:

    msbuild BuildFromTrunk.build /t:Build-All

    3 minutes and 44 odd seconds later, Rhino.Commons.dll appeared.

    One thing to note, this is built of the trunks of NHibernate and Castle Project code, so those bits may or may not be as stable as the most recent public releases.

  • G3 on the way

    It is with great excitement that I can now announce that we’re expecting our third child, due in May next year.

    Not specifically “one for the country”, but at least with our extension almost finished we should have enough room for everyone!

  • Strongly-typed primary key identifiers

    Often the primary keys for tables are integer types. One problem can occur when you accidentally use the OrderID when you really meant to use CustomerID. This bug can happen inside the database and it can also arise in your code data layer.

    One solution for this at the code level is to create custom types (eg. OrderIdentifier and CustomerIdentifier) so that the compiler will throw an error if you try and assign or compare different types.

    The down-side to this is that because Integers are value types, you can’t just inherit from the Integer class. Instead you need to store the actual integer value inside the class and expose it through a property.

    eg.

    Public Class OrderIdentifier

    Private _value As Integer

    Public Property Value() As Integer

    Get

    Return _value

    End Get

    Set(ByVal Value As Integer)

    _value = Value

    End Set

    End Property

    Public Sub New()

    End Sub

    Public Sub New(ByVal value As Integer)

    Me.Value = value

    End Sub

    End Class

    I’ve also noticed that NHibernate doesn’t like having custom types for primary keys, as it tries to use the System.Type.IsAssignableFrom method to see if it can convert an Integer to the OrderIdentifier object (which fails).

    I’m not sure that there’s a workaround for that, as I think it would require a class to inherit from the Int32 structure, which isn’t possible.