With all the respect that I have for the Castle projects and team members, their are two things I don’t like about the projects.
– Visual Studio Integration rather then a command line tool
– The scaffolding
So instead of complaining, here’s what I’ve done: The Generator, mouhaha! :
To compile and run:
1. Run svn co http://svn.castleproject.org/svn/castlecontrib/generator/trunk
2. Run nant
in the base directory to compile
3. Run generate
to get help
It’s a fully customizable code generator written in Boo and templates with ASP style syntax. I’ve made 4 generators: controller, model, generator and scaffold.
The scaffold generator is heavily inspired by RoR, it generates real code you can modify for the controller, the views, layouts, css and tests. The CRUD views will look similar to current MR scaffold with the difference that the code is live in you project so you can add a field, color, validation, change the workflow without copy pasting for the last controller you’ve done! Plus you already got some running tests! (just 2 simple for now)
To use it :
Edit the file Generators\Config.boo to fit your project structure
run bin\generate from your project root folder.
This is a work in progress so contributions or comments are welcome.
Oh and I almost forgot, a short video: Video
This is cool. Do you have any an instruction, doc or C# version of the generator available. I don’t know BOO.
Not any doc at the time but I think the generators code is pretty self explanatory. Plus you can use the generator code generator to create a new generator template to start with. If you have any questions I’ll be please to answer them.
Two things would make this much more useful:
* allow configuration of the area which the controllers/view are in (so allow e.g. /administration/product/edit.rails?id=1
* allow configuration of the file extension – i use .rails and not .aspx
Done!
The source is at:
https://svn.sourceforge.net/svnroot/nproject/Generator
run nant at the base directory to compile.
Thanks for the feedback
That’s excellent, thank you. I’ve checked it out from SVN, it’s not immediately obvious what you’ve changed to support Areas… Can you explain how this would work?
Hmm, still doesn’t work, for example in the scaffolded lists I get:
$HtmlHelper.LinkTo(“Add a new Product”, “Products”, “New”)
Whereas I think it should be:
$HtmlHelper.LinkTo(“Add a new Product”, “administration/products”, “New”)
And I don’t see a way of configuring it to do this.
You’re right… I’ll try to fix this ASAP. But you can easely modify every template you want. They are located in GeneratorsScaffoldTemplates, the syntaxe is asp like.
Yeah, I could hard-code the Area into the scaffolding templates. But a variable for the Area would be the nicest way so that’s why I brought it up 😉
Fixed in rev 60.
https://svn.sourceforge.net/svnroot/nproject/Generator
(no need to recompile, just update the Generators directory)
When you generate a new scaffold the controller and tests are placed in the namespace of the area, ex.: MyApp.Controllers.Admin for the area Admin. Links and views locations have been placed. Everything should work fine now!
Thanks for the interest!!
That is absolutely brilliant. Thank you very much!
I can’t checkout nproject!
Is it still up?
I think sourceforge’s svn server is down for a moment, try again in a couple of hours.
Hi MAC,
Are you using Monorail in production?
I use MonoRail, ActiveRecord, Generator and Migrator at work and on my personnal project (NProject).
If that’s what you mean by production, then yes!
I guess I mean a live site, on the internet or an intranet.
I am hesitant to use a beta product, but I can’t resist. I am coming from Java and more recently Ruby to ASP.NET, and it seems that the default Mircosoft way (forms, datasets, etc) is not layered or object-oriented.
If I don’t use something like Monorial I would need to create a framework myself. That would not be productive.
In any case, any advice is appreciated.
Henri
Demo version of NProject is currently hosted on a live server http://nproject.org. But it’s down for now : (’cause of dependencies related to NSvn a subversion binding for .NET). But it worked perfect before. I’ll fix this ASAP so check back later.
MonoRail surely has some weakness, but beeing an open source project I know that if it’s not going the way I want, I always have the option to fork and start my own version. That’s alot better then starting a framework from scratch! That’s the power of open source!
NProject is now working!!!
Check my post for infos.
Hi Marc,
First my compliments for your work! Very impressive..
BUT…. could it be possible that you’re generator could generate a application skeleton? Something like TreeSurgeon does?
Thanks in advance
Peter
I’m working on this one Peter!
Thanks for the suggestion
Are you interested in donating the code to the Castle Project? We would probably need to convert to C# as we can’t force people to have boo (or any non-standard tool)
Thing about it.
Cheers,
hammett–>