Monday, February 25, 2008

CopySourceAsHtml for Visual Studio 2008

I ported the CopySourceAsHtml to work with Visual Studio 2008.  There are some workarounds to get the existing addin to work with Visual Studio 2008 but they all assume you have 2005 installed, which I don't.  I recompiled from source, built against .NET 3.0, removed some crufty code thanks to FxCop and removed a call into olepro32.dll that wasn't needed.  I'll provide the updated source if anyone cares, this is just a quick posting as I'm flying out the door :)

To Install

  1. Download the CopySourceAsHtml AddIn zip.
  2. Unzip to \My Documents\Visual Studio 2008\Addins, if the Addins folder doesn't exist just create it.
  3. Restart Visual Studio (you did close it first right?)
  4. Right-click some selected code and you'll have a new Copy As HTML... menu item, that's the gold, click it. 
  5. Check the boxes in the dialog that comes up to your delight and then paste into your blog software or forum post.
  6. IMPORTANT: This Addin generates HTML code, so remember to switch into the HTML view in your blog software or forum edit box. 
  7. Bob's yer uncle

Sample

This is how a chuck of code looks when pasted (you'll notice it uses your exact color and font settings):

[Test]
public void Select_ColumnList_Specified()
{
    SqlQuery qry = new Select("productid", "productname").From(Northwind.Product.Schema);
    ANSISqlGenerator gen = new ANSISqlGenerator(qry);
 
    string selectList = gen.GenerateCommandLine();
 
    Assert.IsTrue(selectList == "SELECT [dbo].[Products].[ProductID], [dbo].[Products].[ProductName]\r\n");
}

0 comments:

Flickr

www.flickr.com

Tags

Pandora

Blog Archive

Currently Reading