nspectre 1.0.1 release

13 05 2007

I’ve released version 1.0.1 of nspectre.  This version has one new feature: the ability to use JSON to store configuration.  Jayrock provides the JSON capability.
The purpose of adding JSON support to nspectre is to demonstrate the capability of storing configuration in multiple formats.
Download the new version of nspectre here.





nspectre 1.0.0 released

10 03 2007

nspectre 1.0.0 has been released.  This version has a new type of simple specification which allows you to call functions.  Being able to call existing functions means not having to dabble in template language and being able to unit test the existing functions.  If you want to create a function for use as a specification it needs to be declared public and must return IFunctionResult (there’s an implementation of IFunctionResult in nspectre if you want to use it - just remember that passing an error to the constructor will automatically set the outcome to false, otherwise the outcome will be true.)  Bindings are used to pass arguments to the function - and if you declare Context or ILogger as arguments, they will be automatically wired up without you having to lift a finger.
In addition to this new feature, there’s also an enhancement to the way assemblies are referenced.  Some users were having an issue with web applications at runtime getting references to assemblies.  So the new version not only adds references to assemblies containing candidate types or existing functions, it also adds references to any assemblies these containing assemblies reference.
Go and try it out.  The example project that comes with the source project is a great place to start.  Download it here.





Upcoming release

18 02 2007

nspectre is nearing a 1.0 release.  The new functionality that will be in 1.0 is the ability to use functions for specifications (instead of templates.)  I’ve completed the code that provides this functionality and amended the schema accordingly.





A little more validation

10 02 2007

Version 3.0 of the Enterprise Library contains a Validator Block - there’s a CTP here.  Looking at the details on Tom Hollander’s blog, this block has the closest functionality to nspectre of any framework I’ve come across.  There is a difference in design philosophy - nspectre is designed to have as few dependencies as possible.  There are dependencies between the Enterprise Library blocks.





First Mono Release of nspectre

27 01 2007

I’ve released a mono version of nspectre 0.9.0. Get it here.

The NAnt buildfile is part of the source if you want to build it yourself (use the release or debug target.) The buildfile is still a little raw, but it does what’s needed right now.

I haven’t tested the mono version on Windows, so it may not work.





One More Thing

9 01 2007

I ran into another issue with the nspectre Mono adventure I posted about yesterday. In order to load the assemblies in the bin folder, I passed the Location property of the assembly of a given type (ResourceLocator in this instance) to the constructor of FileInfo. I then used the Directory property to get a DirectoryInfo object with the intention of looping through the files in said directory. I was able to do this but the location of the directory was /home/user/files:/home/user/somefolder/someotherfolder (you get the gist.) As a short term measure I wrote a line (or two) of code to strip out the colon and all that precedes it. So I succeeded in getting it to work, but I’m sure there’s a better way or that I’ve missed something.

I have to say that I am mightily impressed by Mono. When I think of what nspectre is doing, only running into one real issue (Assembly.Load) is quite something.





Monkeying around

8 01 2007

Over the last couple of days I’ve got nspectre working under Mono. I hope to be able to release a patched version later this month. Here’s how I got it to work. I installed NAnt 0.85 on Ubuntu 6.10 (which I run in Parallels.) I found this link via Cory Foy that shows how simple it is to install NAnt on Mono.

UPDATE: At this point I built TemplateEngine. I used MonoDevelop to build it - no issues to report.

With Nant up and running, I created a build script for NSpectre. To get started, the build script only builds NSpectre.Core, NSpectreExample and NSpectreExample.Entities. Once I had these compiled (on my set up, the csc task in NAnt targets gmcs by default - very impressed), I ran them.

And ran into problem number 1. It appears that Mono implements Assembly.Load differently to .NET. See here for further detail. As a short term fix, I modified ResourceLocator by adding a type initialiser to load all assemblies in the bin directory. I’ll take another look at this, there may be a better way of doing it, but for now it works.

Problem number 2. I set NAnt to use dynamic prefixing for the resources. The namespaces it uses are different to those that VS .NET would use - VS .NET would use the project namespace as the root namespace, whereas Nant uses the name of the folder that contains the project (for subfolders the behaviour is the same.) Pretty easy to fix - modified references in code and config files to use the NAnt generated namespaces.

Problem number 3. One hardcoded (a constant) backslash (used in Engine.) Oops. Modified to a forward slash for the purposes of getting it to work.

Problem number 4. NSpectreExample uses Win32 API calls to change the foreground colour of the console (.NET 2.0 supports this in managed code, so this won’t be a problem in the future.) Unsurprisingly, Win 32 API calls don’t work in Linux. So, I commented these lines out for now.

And that’s it. OK, so there were a few more issues along the way. But the other issues were about getting the build script “right” - in this case getting the csc tasks to build nspectre as closely to the way VS .NET does as possible.

So, a little more investigation, some minor modifications, some clean up of the build script and I’ll be able to release a Mono’ed version of nspectre.





Action Man

17 12 2006

Roy Osherove has posted about a validation framework called Validation Everywhere.  It has a lot in common with nspectre (for instance, both make it easy to unit test your validation logic) - the approach is a little different and Validation Everywhere doesn’t seem to have actions (yet.)  Actions are a key concept in nspectre.  They allow you to group specifications.  In practice this is likely to mean things like Add or Delete.  Because actions can inherit from other actions, specifications that are common to a number of specifications can be grouped together and don’t have to be repeated.
I have been asked before why nspectre doesn’t use attributes.  The answer is linked to actions.  A property on a class may need to be a certain length.  It is likely that this need is context sensitive - i.e. we don’t need to check if the property is of the correct length if the object in question is being deleted.  Moving the knowledge of the context outside the class makes it easier to maintain.  It also creates possibilities that would otherwise be very difficult.  For instance, I have spoken to one developer who maintains a site where the validation rules are user specific (e.g. when each user registers and is set up, they can choose how long fields should be and which are mandatory.)  This requirement could be supported in nspectre by having a configuration per user (and one ValidatorFactory per user.)  I guess it’s also worth noting that Context can be used to pass runtime information to specifications.  Context could conceivably be used to the same end - the better approach would be determined by how different the logic was between users.





nspectre 0.9.0

3 12 2006

I’ve released nspectre 0.9.0.  This release contains a schema against which XML configuration files are validated.  There is also an XSL so that existing files can be updated to the new format.

The other new feature is templated error messages.  The properties used by a template can now be used in the error message.

Get it here.





Half a million dollars

8 11 2006

According to ohloh, that’s what it would cost to develop nspectre from scratch.  Ohloh provides some interesting analysis of opensource projects.  Although I’m not sure quite how it’s figured that 73% of the code is HTML.  I wonder if it’s the XML comments.