Code Analysis: How to Correctly Resolve CA1300 – "Specify MessageBox Options"

This is the first installment of what I hope to be many short bits of guidance about correctly resolving some of the more complex warnings coming out of FxCop and Code Analysis. The CA1300 warning is specifically about the right-to-left or left-to-right reading order of a message box.  The documentation for the warning alludes that a message box doesn't automatically inherit the containing form's reading order or the reading order from the user's current culture.  Although, I can't find any documentation that confirms either. In any case, this is a rather complex warning to resolve, you possibly have to traverse the form's … Continue reading Code Analysis: How to Correctly Resolve CA1300 – "Specify MessageBox Options"

Using Toolbox for Code Snippets in Visual Studio 2005

Just noticed today that you can drag text into the Toolbox then repeatedly drag it back out wherever you want, into a Visual Studio source window. Simply select some text in a source window, drag it over to the Toolbox tab (assuming you have Toolbox set to Auto Hide), wait for Toolbox to expand and drop the text wherever you want it. Now you can simply open up the Toolbox and drag-drop that text whenever you want, much like a code snippet; but much faster (and without literals).

Visual Studio 2005 Service Pack 1 Beta

As with any Beta, it's not wise to think of it as "stable" and expect it to work as reliably, or be as tested as an RTM version. But, I've found the second of what I consider blocking issues with SP1 that leads me to think it's time to test the uninstallation.  I independently found that enabling Code Analysis for C/C++ spits out what seems like verbose tracing information that causes Visual C++ to view building with Code Analysis turn on to fail a Build.  I found that someone else had found this already and logged it on Connect: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=218742.  Breaking a … Continue reading Visual Studio 2005 Service Pack 1 Beta

Add Visual Studio 2005 Intermediate Files to Windows Disk Cleanup

A few years ago I remember a small little Code Project project about a Windows Disk Cleanup component that would cleanup VC6 files.  I had always meant to look into that for VS2005 when I had the time. Well, I had a look at the interfaces that the the Disk Cleanup applet uses and it turns out you can add cleanup items to Disk Cleanup without writing a single line of code.  There is a “fallback” cleanup COM component (DataDrivenCleaner) that you can reuse for situations where cleanup can be defined by a directory and/or set of files/wild-cards.  Visual Studio 2005 … Continue reading Add Visual Studio 2005 Intermediate Files to Windows Disk Cleanup

Schedule at Least a Three Hours When Installing Visual Studio 2005 Service Pack 1 Beta

Yesterday, I got Rob Caron's, the Visual C++ Team's, and various other emails about the just-released VS 2005 SP1 Beta. After getting my approval to download it, I did just that.  I then quickly proceeded to install it.  It took well over 10 minutes to inform me that I have Web Application Project add-in (WAP) installed and it must be uninstalled before proceeding.  10 mins?  I knew SP1 has Web Application Projects built-in, so I guess I understand.  But, 10 mins?  So, I pressed OK and waited a couple more minutes before the dialog went away.  I then went to uninstall … Continue reading Schedule at Least a Three Hours When Installing Visual Studio 2005 Service Pack 1 Beta

Visual Studio Revert-to-saved macros

I often run into situations where I’d like to undo all the work I’ve done in a file.  Some applications refer to this as Revert-to-saved.  Visual Studio 2005 does not seem to have a function to do this.  So, I’ve written a couple macros to do this. The first, RevertToSaved simply calls Undo until it can’t undo anymore.  This is much faster than holding the Ctrl-Z key down, and keeps your undo buffer.     Sub RevertToSaved()         While DTE.ActiveDocument.Undo() = True           End While     End Sub The second, RevertToSaved2, is a little more brute force–it simply … Continue reading Visual Studio Revert-to-saved macros