Archives

Archives / 2003 / May
  • How do you use CodeSmith w/o the custom tool?

    Christopher asks this question:

    How do you use CodeSmith w/o the custom tool? Point me to some docs I've missed, I'd love to see what the hoo-ha's all about. ;-)

    CodeSmith is primarily a stand alone template-based code generator application.  The VS.NET custom tool is just an additional way to use the tool.  To use CodeSmith w/o the custom tool, you simple double-click the CodeSmith shortcut if you used the installer or CodeSmith.exe if you used the .zip file version.  This will bring up the CodeSmith Explorer window which basically lets you see all the templates in a given directory and it's sub-directories.  You can then click on one of the templates to execute it, it will bring up a window to allow you to provide context information for your template and then when you click generate it will display the generated code on the right hand side.  On the other hand, the custom tool allows you to include a property set XML file in your VS.NET project that will output code directly into your project.  Here is a sample property set XML file:

    <?xml version="1.0" encoding="utf-8" ?>
    <codeSmith>
     <namespace>CSharpCodeGeneratorSample</namespace>
     <imports>
      <import namespace="System" />
      <import namespace="System.Data" />
      <import namespace="System.Data.SqlClient" />
     </imports>
     <propertySets>
      <propertySet>
       <property name="SourceTable">
        <connectionString>Data Source=(local)\NetSDK;Database=Northwind;Integrated Security=true;</connectionString>
        <providerType>SchemaExplorer.SqlSchemaProvider,SchemaExplorer.SqlSchemaProvider</providerType>
        <tableName>Customers</tableName>
       </property>
       <property name="IncludeComments">True</property>
      </propertySet>
      <propertySet>
       <property type="SchemaExplorer.TableSchema" name="SourceTable">
        <connectionString>Data Source=(local)\NetSDK;Database=Northwind;Integrated Security=true;</connectionString>
        <providerType>SchemaExplorer.SqlSchemaProvider,SchemaExplorer.SqlSchemaProvider</providerType>
        <tableName>Orders</tableName>
       </property>
      </propertySet>
     </propertySets>
     <template path="businessobject.cst" />
    </codeSmith>
    

    When this file is included in your VS.NET project and the Custom Tool property of the file is set to CodeSmithGenerator, then everytime you save this file it will execute the businessobject.cst template for each property set (in this case there are two sets of properties) and the output will be generated into a code-behind file.  This allows you the ability to simulate generics in that you have a single template and there are multiple instances of that template being generated based on different properties.  When you make a change to the template, all generated code reflects that change.

    I hope this helps straighten things out.

    Read more...

  • More votes for CodeSmith

    I'd like to second this - CodeSmith is shaping up to be a huge timesaver in the group I work in. The code templates are pretty intuitive once you realize that they're basically just like inline ASPX code, so if you've hacked inline ASP for years you'll be right at home.
    ...
    This is an amazing product. It paid back our time investment quickly, and with huge dividends.
     
    First of all, thanks for the glowing review!
     
    I'm not sure if you know this or not, but CodeSmith does not constrain you to inline code.  You can do one of two things:
     
    1. Include a Src attribute in your CodeTemplate directive.  When this attribute is specified, just like in ASP.NET, it will dynamically compile the source file into the same assembly as the template code.  You will also need to specify the Inherits attribute to have your template derive from a class in the source file.
     
    2. Create your base template class in Visual Studio.NET and compile it to a .dll.  Then using an Assembly directive add a reference to this .dll.  You may then specify an Inherits attribute in the CodeTemplate directive to inherit from a class in the assembly or just make use of any other class in the assembly within your template code.  You can also use an Imports directive to avoid having to type fully qualified type names.
     
    Basically, CodeSmith tries to resemble ASP.NET as much as possible.  And, with the glaring exception of the equivalent of server controls and data binding, it does a pretty good job of this.

    Read more...

  • I want to play on Saturn!

    In case you missed it, Nikhil has posted a screenshot of the new Web Matrix.  Looks pretty cool, but I'm wondering about the theming comment.  Now, is web matrix simply taking advantage of the built in windows theme, or are they doing something magical to give their app a new theme. 

    My guess is the old watercolor theme from some of the Whistler builds makes a comeback in Longhorn.  If you are curious, you can download a hacked together theme from TweakXP.  Note, the copy from TweakXP isn't for the weak of heart.  It involves replacing your uxtheme.dll in recover mode with a version hacked out to enable custom themes...

    [Phil Scott's WebLog]

    I wouldn't call it magic, but if you look through the code using Reflector then you will notice that they have an entire managed UI framework (codename Saturn) with all kinds of bells and whistles.  There are all kinds of goodies like the syntax editing control, enhanced versions of nearly every single Windows.Forms control, XP style menus and toolbars, etc, etc.  Basically, Web Matrix is their playground for cool stuff and we are not allowed to play.  :-(  It's very obvious that they have spent a ton of time building this framework out.  It would be awesome if we could play too!

    Read more...

  • CodeSmith 2.0.1222 Released!

    Thank you to everyone that helped make this release happen!!

    Here is a list of the changes for this release.

    • Removed expiration.
    • Added CodeSmithConsole.exe to enable processing a .xml property file from the command line. (CSharpCodeGeneratorSample and VBCodeGeneratorSample folders)
    • Created installer.
    • Added a Visual Basic Code Generator Sample (VBCodeGeneratorSample).
    • Added a designer for the DatabaseSchema object.
    • Added Owner property to TableSchema, ViewSchema, and CommandSchema and fixed bug relating to tables, stored procedures and views were assuming dbo as an owner.
    • Fixed problem where SchemaExplorer would fail if collation was different from the master database.
    • Added view support to SchemaExplorer.
    • Fixed problem with SQL7 compatibility and column descriptions.
    • Updated CollectionGen templates from the latest CollectionGen release.
    • Changed to a build system instead of going on and on forever with beta builds.
    • Dropped support for Visual Studio .NET 2002. The Visual Studio features will only work with the final release of Visual Studio .NET 2003.
    • Dropped RedRiver from all namespaces. If you have templates that refer to RedRiver, you will need to update them.

    Download Now

    Read more...

  • CodeSmith Legal Update

    RedRiver and I have agreed to terms and now I just need to go get my signature notarized on the contract.  I believe that we could see a new CodeSmith release by this weekend.

    Thanks again to all those who contributed to this effort!

    Read more...

  • Typed DataSet's vs. Custom Collections

    I have been reading the blog entries (here, here) lately about Typed DataSets and it makes me wonder if anyone has really sat down and compared the performance of a custom object/collection (using a data reader to populate) to a Typed DataSet?  Performance was critical to us so we decided to go the custom collection route and we were very happy with the results, but we never actually sat down and figured out what the performance difference was.  We assumed that considering all the bells and whistles that are associated with DataSets that custom collections would be a major performance win.  And since we were using CodeSmith to generate those custom collections, it wasn't any more work to use them.  Does anyone know of any benchmarks that I could look at?

    Read more...

  • CodeSmith Takes Over For CollectionGen

    http://www.sellsbrothers.com/As of today, the functionality of CollectionGen has been sucked into Eric Smith's CodeSmith. I asked Eric to take on these features because CodeSmith does all of what CollectionGen does and more. All new feature requests/bug reports should go his way. Of course, feel free to continue to use CollectionGen as a model for VS.NET Custom Tools.

    Posted by Chris Sells on Mon, May 5, 2003 @ 10:31AM

    [sellsbrothers.com: Windows Developer News]

    CodeSmith has officially taken over the CollectionGen tool from Chris Sells.

    Read more...

  • Next CodeSmith Release Ready

    Here is a list of the changes for the next version of CodeSmith. It is ready to release now, but I am not legally able to release a new version until ownership has been transferred to me from RedRiver Systems. So far I have $100 of ~$300 (this is the revised estimate after speaking in detail with several lawyers) needed for lawyer fees to make the transfer happen.

    • Removed expiration.
    • Added CodeSmithConsole.exe to enable processing a .xml property file from the command line. (CSharpCodeGeneratorSample and VBCodeGeneratorSample folders)
    • Created installer.
    • Added a Visual Basic Code Generator Sample (VBCodeGeneratorSample).
    • Added a designer for the DatabaseSchema object.
    • Added Owner property to TableSchema, ViewSchema, and CommandSchema and fixed bug relating to tables, stored procedures and views were assuming dbo as an owner.
    • Fixed problem where SchemaExplorer would fail if collation was different from the master database.
    • Added view support to SchemaExplorer.
    • Fixed problem with SQL7 compatibility and column descriptions.
    • Updated CollectionGen templates from the latest CollectionGen release.
    • Changed to a build system instead of going on and on forever with beta builds.
    • Dropped support for Visual Studio .NET 2002. The Visual Studio features will only work with the final release of Visual Studio .NET 2003.
    • Dropped RedRiver from all namespaces. If you have templates that refer to RedRiver, you will need to update them.
    If you would like to see these new features/changes released, please help support CodeSmith by clicking on the image below and making a donation. All donations are appreciated!

    Read more...

  • Inside the new ValidateRequest feature

    Victor Garcia Aprea has a great detail about the new validation request feature from Microsoft.

    Great, but my point  is still valid,  this break the rules.

    Because I think about production environment. Because I talk about sites went live since few months, and suddenly a new rule come without any publicity, and change the rules, creating errors.

    This is what I call a very bad mistake to implement a new rule which break your code.

    I would prefer to have this feature having a false value by default, and some strong recomendations by .Net team to turn it on rather than now having to check every single page.

    [Paschal L]

    I must say that I completely disagree.  Microsoft's job is to make their software as secure as possible right out of the box.  They did an incredible job with Windows Server 2003 in this area and .NET 1.1 is part of that effort.  I was bitten by this change on 3 websites, but it's pretty simple to add an attribute to the web.config and fix it.  I think they did the right thing.

    Read more...