A day in the life (of a developer) RSS 2.0
 Sunday, August 17, 2008

CodeRush builds an internal source tree of your C# or VB.NET code. It also has code generating ability - that is, you can take a portion of the tree and generate C# or VB.NET code from it. That got me to thinking about a way of leveraging this ability to build a simple code translator so you could do something like open up a C# file and view the VB.NET equivalent in a tool window (or vice-versa). It turns out the code to do something like this is really straightforward; it's a single method call once you have a reference to the code elements. It doesn't always generate the correct set of code, but it's still really helpful. You basically move the cursor around and the window will display the translated code that is currently "in scope". That is, if you're inside of a method it will show you code for that method. If you move the cursor out to the class, it will show you that class.

To install it, just copy it to your plug-in directory (usually C:\Program Files\Developer Express Inc\DXCore for Visual Studio .NET\2.0\Bin\Plugins\). When you start up Visual Studio a new menu option will appear under DevExpress > Tool Windows > Translator. The window shows a number of different .NET languages, but in reality CR only supports VB.NET and C#.

CR_Translator

BTW - I've mentioned CodeRush/Refactor! and while that's a commercial product you can also download CodeRush by itself for free (and use any third party plug-ins or write your own). You just don't get any of the built-in templates or refactoring tools that the commercial product offers.

Oh, you can download the plug-in from here: http://www.rcs-solutions.com/Download.ashx?File=CR_Translator.zip or from the community plug-in site in a few days.

Links:

http://www.devexpress.com
http://code.google.com/p/dxcorecommunityplugins/

Sunday, August 17, 2008 11:13:43 AM (Eastern Standard Time, UTC-05:00)  #    Comments [2] -

CodeRush | Visual Studio
 Friday, August 08, 2008

It looks like it's the week of CodeRush/DXCore plug-ins (I still have one more plug-in coming up).

This plug-in just lets you collapse an XML comment tag to one line (I'll explain it a bit more below). It was actually written as a Refactoring (so it appears when you hit the refactoring key or wait for the ellipses to appear below the code). I put this one together a few days ago and was planning on releasing it after I had a chance to live with it for a while to see if there were any changes or bugs I needed to address. But someone on the DevExpress forums recently posted about wanting a plug-in which did the same thing so I decided to just release it right now.

So what does this really do?

When you add an XML comment to something like a property or field, you end up with the following (in C#):

/// <summary>
///
/// </summary>
private int m_someValue;

The cursor is positioned on the second line. After installing this refactor, you can hit the Refactor key (which I mapped to just the ` key (instead of Shift or Alt or Ctrl ` , whatever the default is) and this comment will get collapsed down to one line:

/// <summary></summary>

This can help eliminate some of the visual noise of the comment, especially if it's just a short comment.

If you have a muli-line comment, it actually collapses it in two stages (that is, you can issue the refactoring twice), so for example:

/// <summary>
/// This is my multi-line
/// comment about nothing.
/// </summary>

The first time you collapse it you end up with:

/// <summary>This is my multi-line
/// comment about nothing.</summary>

The second time you collapse it you end up with:

/// <summary>This is my multi-line comment about nothing.</summary>

You can download the code from the download section on my site or the community site. Like before, there will probably be a few day delay between when it's available here and when I get it put up on the community site.

To install it, copy it into your C:\Program Files\Developer Express Inc\DXCore for Visual Studio .NET\2.0\Bin\Plugins\ folder.

Links:

http://www.rcs-solutions.com/Download.ashx?File=Refactor_Comments.zip
http://code.google.com/p/dxcorecommunityplugins/

Friday, August 08, 2008 6:48:44 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

CodeRush | Visual Studio
 Tuesday, August 05, 2008

I've been meaning to post this up for a while but never seemed to get around to it. I've been using CodeRush/Refactor! (CR/R!) from DevExpress for a few years now and this was actually the first plug-in I wrote for it. If you're not familiar with CR/R! it's sort of Intellisense on steroids with a bunch of refactoring tools thrown in. OK, that description really doesn't do it justice - I'd suggest taking a look at a few of the videos they have available over on the DevExpress site to get a better idea of what it does. I'd put CR/R! in the "must have" category for any .NET developer. It's actually annoying to use Visual Studio without it installed.

At any rate, this plug-in does nothing more than make it easy to insert a comment that contains the developers name or initials and the date of a change. For example:

// PCM - 8/4/2008 -

Or, if you happen to be located on an XML comment line, it inserts the following:

/// <developer>Paul Mrozowski</developer>
/// <created>08/04/2008</created>

It's language agnostic, so this should actually work in VB.NET as well (it uses the '/''' comments instead). I've tied it to the CTRL-Insert keypress but you can set it to whatever you'd like. To install it, copy it into your C:\Program Files\Developer Express Inc\DXCore for Visual Studio .NET\2.0\Bin\Plugins\ folder. Then start up Visual Studio and go to DevExpress, Options. You should see a new tree option, "Developer Initials". Fill in your name and initials and select whether you'd like it to insert your initials for a line comment or your full name. Then go to IDE > Shortcuts. Expand the Code folder. I created a new folder named "Custom". Click on the icon for a new keyboard shortcut. On the right-hand side, enter the keyboard shortcut (mine is Ctrl+Insert), then in the Command combo select "Add Initials". Then hit OK.

CR_Initials

CR_Initials2

Exit out of Visual Studio and go back in. At this point the plug-in should be active. Try it out by hitting your shortcut key on a new line (or, enter an XML comment. Hit enter, on the new XML comment line hit the shortcut key).

You can download it from here (http://www.rcs-solutions.com/Download.ashx?File=CR_Initials.zip) and it may show up on the DX Core Community Plug-ins site at some point.

Links:

http://www.devexpress.com
http://code.google.com/p/dxcorecommunityplugins/

Tuesday, August 05, 2008 7:44:45 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

CodeRush | Visual Studio
 Thursday, April 03, 2008

I've been playing around a bit with WPF lately (with Visual Studio 2008) and was disappointed that there wasn't any intellisense in the designer (like what you'd see in the ASP.NET designer). I happened to mention this on the UT and John Fenton there pointed me to this link:

 

http://blogs.msdn.com/windowssdk/archive/2008/02/22/workaround-installing-win-sdk-after-vs2008-breaks-xaml-intellisense.aspx

 

Apparently installing the Windows SDK after installing VS2008 breaks XAML intellisense. The link above walks through fixing it (very simple registry entry fix).

 

Links

 

http://www.universalthread.com
http://blogs.msdn.com/windowssdk/archive/2008/02/22/workaround-installing-win-sdk-after-vs2008-breaks-xaml-intellisense.aspx

Thursday, April 03, 2008 8:19:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

Visual Studio | WPF
 Wednesday, October 17, 2007

I’ve been trying to get the (highly regarded) CopySourceAsHtml add-in to work under Visual Studio to make it easier to post code samples. Every time I tried loading it, it was failing with:

The Add-in 'CopySourceAsHtml' failed to load or caused an exception.
Would you like to remove this Add-in?
If you choose yes, the file it was loaded from, '\\wtz-srv-dc01\Users\paul.mrozowski\My Documents\Visual Studio 2005\Addins\CopySourceAsHtml.AddIn', will be renamed.
Error Message:
Error number: 8013150a

I tried downloading the source, recompiling, making some suggested changes to the control references. Nothing seemed to help. As soon as I attempted to activate the add-in, it was failing. Then it suddenly occurred to me: what if it’s related to the fact that “My Documents” is on a network drive? To test this idea, I created a new local folder, then when into Tools > Options > Environment > Add-in/Macros Security. I added a new local folder which had a copy of the add-in and exited VS and restarted. Finally, I when to Tools > Add-ins and reselected the CopySourceAsHtml add-in. No errors!

options

I copied and pasted some code (and selected Override for the font to add Courier New as a secondary font). (random code shown below).

 

        /// <summary>

        /// Process events from the grid

        /// </summary>

        /// <param name="source"></param>

        /// <param name="e"></param>

        /// <developer>Paul Mrozowski</developer>

        /// <created>10/16/2007</created>

        protected void grdTemplates_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)

        {           

            if (e.CommandName == "Edit")

                this.EditRecord(e.Item);

            else if (e.CommandName == "Cancel")

                this.grdTemplates.EditIndexes.Clear();

            else if (e.CommandName == "Add")

                this.AddRecord();

            else if (e.CommandName == "Test")

                this.TestQuery(e);

            else if (e.CommandName == "Update")

                this.UpdateRoles(e);

        }

 

Here's a screenshot as a comparison:

 

htmlComparison

 

 

Links:

CopySourceAsHtml

http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/

Getting it to run under VS 2008 Beta 2

 http://diditwith.net/2007/08/16/CopySourceAsHtmlInVisualStudio2008.aspx

Wednesday, October 17, 2007 9:49:58 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -

Developer Tools | Visual Studio


Navigation
Archive
<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Paul Mrozowski / RCS Solutions, Inc.
Sign In
Statistics
Total Posts: 57
This Year: 32
This Month: 0
This Week: 0
Comments: 21
All Content © 2008, Paul Mrozowski / RCS Solutions, Inc.
DasBlog theme 'Business' created by Christoph De Baene (delarou)