mo.notono.us

Monday, September 08, 2008

CodeSmith: Yay, my code is still there...

CodeSmith's templates are now hosted on Google Code, and though the search doesn't find me (huh?  Google not being able to search a text file?), I found my old code myself...

http://code.google.com/p/codesmith/source/browse/branches/
4.x/Templates/DatabaseSchema/StoredProcedureDescriptions.cst

Since almost all my work since day 1 has been hidden behind corporate firewalls, it's nice to see some segments in the wild.

Labels: , ,

Tuesday, April 10, 2007

SubSonic 2.0 goes Beta

Looks like v.2.0 of Rob Conery's (et. al.) excellent SubSonic has reached Beta status.  I used an early alpha build on a project a few months back, and though I'm normally a CodeSmith devotee, the simplicity of SubSonic was refreshing. 

(The use of a build provider to generate the DAL at run time is interesting, but unfortunately conflicts with ReSharper; I ended up using SubCommander and the web based dev tools instead.) 

Labels: , ,

Wednesday, November 08, 2006

CodeSmith 4.0 Released

Eric and his team at CodeSmith Tools have released version 4.0 of the popular CodeSmith.

CodeSmith 4.0 has been released today at the Dev Connections conference in Las Vegas. Here are just a few the new capabilities in CodeSmith 4.0:

  • CodeSmith Projects (.csp) - This feature makes automating your code generation process really easy and consistent whether you are working from inside of Visual Studio 2005, MSBuild, Windows Explorer, a command line / batch file, or CodeSmith itself.
  • ActiveSnippets - Imagine Visual Studio 2005 snippets, but with the full power of CodeSmith available to execute any logic or access any complex metadata (including database schema and xml data) to control the output of your snippets.
  • CodeSmith Maps (.csmap) - This feature will allow you to create dictionary style maps of things like SQL to C# data type mappings.
  • .netTiers 2.0 - The .netTiers templates have been greatly enhanced and included with CodeSmith 4.0.
  • Extended Property Management - You can now edit and add new schema extended properties inside of CodeSmith Studio.
  • Property Persistence - CodeSmith now remembers the property values from the last time you executed a template.

Official Press Release

Personally I have enjoyed great productivity increases using versions 2 and 3 of CodeSmith, and hope to garner even greater benefits in version 4. Especially the CodeSmith Projects and the ActiveSnippets will be very useful to me. Couple that with partial classes in .NET 2 (and 3) and we're looking at a killer featre set.

Labels: , ,

Thursday, October 19, 2006

CodeSmith 4.0 Public Beta released

Eric J. Smith and his team at CodeSmith Tools has released a public beta of CodeSmith 4.0. Full set of changes are here. If you ever do anything repetitive in C#, VB.NET, HTML, SQL, JavaScript, XML - in short, any ASCI based language, and your repetiveness is based on data from a table or an xml document, then CodeSmith can help you get your work done in a fraction of the time spent before. I highly recommend it.

Labels: ,

Thursday, February 16, 2006

.NetTiers - all grown up

.NetTiers is an awesome CodeSmith template suite for generating Data Access Layers (as well as BLL and webservice stubs). I had some VERY limited involvement early on in this project, in the sense that some of my templates were used as the basis for parts of the project. I'm not claiming any more credit than that - but it's fun to find my name in the code...

Eric J. Smith (the creator of CodeSmith) wrote a great article and also created a video tutorial on how to use .NetTiers to Build a Data Access Layer in less than 15 minutes. Actually, once the code is downloaded and intalled and the proper settings are made, it takes the tool much less time - only 1 minute 45 seconds to generate the DAL, BLL and WS layer for our database with 100 tables.

Labels: ,

Thursday, December 22, 2005

CodeSmith Community

The new CodeSmith Community has been launched. Looks like Eric's partnership with Telligent is paying off.

Labels: ,

Thursday, November 10, 2005

CodeSmith: DAL.cst - a Stored Procedure(s) wrapper method generator for use with MS DAAB

I submitted an update to my DAL-method-generating CodeSmith template to the CodeSmith Peer Support Forum: UPDATED! DAL.cst - a Stored Procedure(s) wrapper method generator for use with MS DAAB

It's still for old .NET 1.1, and the DAAB 2.0. One of these days I'll update it for .NET 2.0 and the Enterprise Library's DAAB

Labels: ,

Friday, July 01, 2005

Is Dynamic SQL in Your Stored Procedures Vulnerable to SQL Injection?

Pencil Bros. Geology, Inc. (a.k.a. Richard Dudley) asks: Is Dynamic SQL in Your Stored Procedures Vulnerable to SQL Injection? and then proceeds to provide a simple but effective CodeSmith template that generates a safe (and efficient) stored procedure for any table.

Labels: , ,

Monday, April 11, 2005

Updated CodeSmith templates

CodeSmith 3.0b3 is out, and my old templates were not compatible as the file-header comments I used did not use the apropriate comment tags. This provided a nice excuse to update them, and test the beta at the same time. Below are the results:

  • Stored Proc Wrapper - a C# wrapper around stored procedures
  • CRUD Procs - a template for creating CRUD procedures (and more)
  • Stored Procedure Descriptions - updated version of my sample template included with CodeSmith, creates Description extended properties for procedures and their parameters
  • Add/Drop Columns - simplifies the process of adding/dropping a column to/from multiple tables

Oh, and CodeSmith 3 is definitely worth the upgrade.

Labels: ,

Thursday, March 17, 2005

DBDocumenter CodeSmith Templates

I've used these before - hopefully this will point to updated versions: DBDocumenter CodeSmith Templates

Labels: ,

Friday, March 04, 2005

3-Tiers Application Templates for CodeSmith

Wow. Impressive work. And apparently I am an actual contributer, though I was completely unaware of the project (see bottom of page): 3-Tiers Application Templates for CodeSmith

Labels: ,

Tuesday, October 19, 2004

Simple VB.NET Entity Template

For CodeSmith of course. This template simply takes one or more tables as input, and spits out the same number of VB.NET classes, with a private field and public property for each column, as well as a constructor with every column as input parameters. Get it here

Labels: ,

Tuesday, September 28, 2004

CodeSmith 2.6 released

I couldn't imagine having to develop our project's data access code without CodeSmith.

Get the new version 2.6 here.

You may want to check out my templates: Stored Procedure Wrapper and Enhanced CRUDS Procedures

Labels: ,

Thursday, August 12, 2004

ASP.NET Forums Debate on Code Generation vs. O/R Mappers

A few days late, I noticed Eric's blog entry about the great Code Generation vs. O/R Mapper debate going on in the ASP.NET Forums.

BrandonC was nice enough to give my Stored Procedure Wrapper CodeSmith template a plug. He incorrectly implies that this template also generates your stored procedures - you need my CRUD Procedures template to do that.

There. Enough self-promotion for today. Of course hardly anyone actually reads this blog, so I'm in no danger of turning into Chris Sells, yet.

Labels: ,

Updated StoredProceduresDescription CodeSmith Template

I updated my StoredProceduresDescription CodeSmith template that Eric has included in the CodeSmith samples. The changelog since the version included in the program download is as follows:

Mar 15 '04 by Oskar Austegard
- Fixed bug in parameter regular expression that stopped looking for parameter comments when it encountered the snippet 'as' even in a comment. Also refactored the RegEx strings themselves to be more readable
Aug 11 '04 by Oskar Austegard
- Fixed bug that failed to escape single-quotes (') in comment strings.
- Fixed bug that failed to create drop statements for Descriptions containing only empty strings:
Replaced check for !Description.Equals(String.Empty) with ExtendedProperties["MS_Description"] != null

Get it here

Labels: ,

Friday, June 18, 2004

Idea: TypedBackgroundWorker

As mentioned before, I have been wanting to create a wrapper around VS's generated web service proxy classes to simplify asynchronous web service calls for quite some time.

I started with David Hill's Simplified Asynchronous Call Pattern, and added necessary features like trapping server exceptions, etc., as well as adding the option to have the user specify the method to call to end the request.

Then Roy Osherove's post reminded me of the BackgroundWorker code coming in C# 2.0 (and Juwal Lowy's 1.1 implementation), and I finally bothered to do a test implementation. Calling a webservice from the background worker is somewhat different from its intended use, I believe, and it may seem counterintuitive to some that you actually have to call the web method synchronously, but from a background thread, hence achieving the same asynchronous behavior.

I like having a component whose events I can wire up through the designer's property grid, but I am not a fan of the contortions one has to go through to call a method with multiple parameters, or one that contains out or ref parameters. There's only a single Arguments and Results object (which of course makes sense for a generic control) but it means you have to build your own structure for passing in/out multiple values.

So my new top side-project is going to be to create a CodeSmith template that will let you select any method (webservice or "regular") and which creates a typed version of the BackgroundWorker. Ideally I'll also have my generic Component designer control by then to simplify the process.

Stay tuned - it will probably only be a year or so before I get it done...

Labels: ,

Friday, June 04, 2004

Reflection and ref

Using reflection, how do you determine if a method parameter is passed explicitly by reference using the ref keyword? E.g.
public Foo(int foo, ref string fooBar, out string barFoo)
{
	//...
}
The ParameterInfo class has an IsOut property which nicely informs you that the barFoo parameter is an out parameter, but IsOut if false for fooBar. There is no IsRef property, and IsRetval doesn't do the trick either. The only way I found to solve this problem was to look at the parameter type name. I stumbled on the following in the help for the ParameterBuilder class:
	// Note that we are passing the first parameter, fundsPool, by reference. Therefore,
    // we need to inform the MethodBuilder to expect a ref, by declaring the first
    // parameter's type to be System.Double& (a reference to a double).
So - the solution is: If a parameter's type name ends with an &, but it is not an out, then it must be a ref. Excerpt from a method in my latest CodeSmith template (more on it later):
...
		typeName = pi.ParameterType.Name;
		if (pi.IsOut)
			pars.Append("out ");
		else if (typeName.EndsWith("&"))
			pars.Append("ref ");
...

Labels: ,

Wednesday, May 05, 2004

Typed DataAdapters....

Sounds like my stored proc wrapper CodeSmith template will be unnecessary in Whidbey: Early Adopter: Tour of the VS2005 Data Experience Not that surprised, really.

Labels: ,

Tuesday, April 27, 2004

Components I'd Like To Build

but for various reason haven't done yet #1. A CodeSmith template to generate WebService stub methods for public BLL classes - user points the template to a class and a webmethod is created for every public method in the class. #2. A CodeSmith template to create a client side component that exposes EndInvoke methods from a webservice as events that can be attached to using the property grid - user selects a webreference and gets the component code #3. A generic CodeSmith template to wrap other CodeSmith templates and save the output to a file #4. A generic Component designer control, that would allow the user to add any component from his solution to the design surface without having to add the component to the toolbox. In other words, it would work the same way as when adding a typed dataset to the design surface.

Labels: ,

Wednesday, February 25, 2004

ONDotnet.com: Copying, Cloning, and Marshalling in .NET [Nov. 25, 2002]

Here's a rather annoying issue I encountered today when trying to write a CodeSmith entity template and needing to do a deep copy
>Copying, Cloning, and Marshalling in .NET by Shawn Van Ness -- Even after spending the last few years with the C# language, Shawn Van Ness recently found it worthwhile to step back and analyze what happens in some very simple scenarios, such as copying a value from one variable to another, or passing those variables as arguments to a method call. And that is the focus of this article.

Labels: ,