Tap My Mind

A Blog by Scott Isaacs

Tag: Links (Page 2 of 2)

HTML Syntax Highlighter

This isn’t new.  I found it linked from Scott Hanselman’s blog.  Even though I didn’t discover it, it’s still pretty cool if you ever plan to post code to your blog, or include it in any other HTML document.  Check out CopySourceAsHTML.  It is a VS.NET add-in that copied selected text and formats it in HTML to look as it does in VS.  Here is a sample.

   12 Class HelloClass

   13     ‘ Private Variables

   14     Private _Who As String


   16     ‘ Public Variables

   17     Public Property Who() As String

   18         Get

   19             Return _Who

   20         End Get

   21         Set(ByVal Value As String)

   22             _Who = Value

   23         End Set

   24     End Property


   26     ‘ Public Methods

   27     Public Function SayHello() As String

   28         Return SayHello(Me.Who)

   29     End Function


   31     Public Function SayHello(ByVal Name As String) As String

   32         Return String.Format(“Hello, {0}”, Name)

   33     End Function

   34 End Class


I found an interesting site linked from here.

Code Generation

So over the last couple weeks I’ve spent a grand total of about 30 hours ironing out what I need from a code generator (screen shot).  It’s not as flexible as CodeSmith is (i.e., no templates), but it does what I want, and it does it every time.  Maybe someday after I add a few more “desired” features and work out more of the kinks, I’ll post the app and/or source up here.  (Translation: You’ll be lucky if you ever see it.)  The source isn’t pretty — it’s just basically a top down application that retrieves schema info from the database and does its best to turn that into VB code.

Anyway, it’s pretty basic.  What it boils down to is that you specify a SQL connection string and it generates the BOL and DAL code as well as the SQL stored procedures need to operate.  The generated code comes from a “template” that I built based on code from other generators, and code I hand-wrote that I wished had been generated.  There was a project at work where, over time, I ended up spending probably 30 hours just on this could-be-generated code alone.  Now that code comes out in about 10 seconds.  Obviously I still have code to write, but the tedious stuff is done.  Here is a brief list of what my code generator does and does not do.

Current Features

  • Generate BOL code (Base and Safe classes)
  • Generate DAL code (Base and Safe classes)
  • Generate SQL stored procedure script
  • Allows for saving and retrieving project settings to a “.genproj” file (I made that extension up myself.  What do you think?)

Possible Future Features

  • Generate Base and Safe classes for the test project (NUnit tests)
  • A simple WebForms data editing tool
  • A simple WinForms data editing tool
  • More options in the UI to select which items to generate on a table by table basis
  • Support for SQL Server views (in addition to tables)
  • Other features that I should have written down, but have since forgotten

Now that I have this code generator complete (with the exception of detailed testing), a friend sent me a link to this blog entry on his site.  It’s about CodeDom.  His blog links to this article on DevX.

I should have researched this first!

It looks like it would have been much more cumbersome to build my generator, but I could have built in to generate code in any language, and even compile it on the fly!  Hmmm.  Should I go back to the drawing board?  I probably should, but doubt that I will…

If you have any feature suggestions for my code generator, list them here as comments, and I’ll consider adding them.  My goal isn’t for this to become the super-awesome-generates-code-for-every-situation code generator.  I just want it to save me time on the normal, tedious, boring, everyday stuff!

Did you know…

…47 countries have re-established their embassies in Iraq.

There are a few interesting, less-than-publicized facts about the current state of things in Iraq on the Lead21 site, here: Why Don’t We Hear About This?

Page 2 of 2

Powered by WordPress & Theme by Anders Norén