Writing Better Managed Code

Did you know there is a managed code analysis tool in VS 2005?

Well, now you do. The managed code analysis tool can warn you when your code does not follow a set of good practices.
For those of you that are familiar with FxCop, the managed code analysis tool in VS 2005 serves the same purpose. 

On your managed project in VS 2005, you can right click on the project, then click on Properties and then on the Code Analysis Tab.Then make sure to "check" the Enable Code Analysis checkbox. You may also select which rules you want to be run on your code.   

After you enable code analysis, next time you build your code you will see many warnings related to the rules that you enabled.

Even though fixing the code analysis warnings may seem like a burden, it may actually increase your productivity and the usability of your managed assembly. For an in-depth explanation of the warnings you may get, you can visit http://msdn2.microsoft.com/en-us/library/ee1hzekz.aspx.

I hope you find this helpful.

 -Luis Cabrera



Comments (7)

  1. Jorrit says:

    The image refers to "file:///C:/DOCUME~1/luisca/LOCALS~1/Temp/msohtml1/01/clip_image001.gif". Please fix 🙂

  2. Unless something has changed, this feature is only available with one of the Visual Studio Team System SKUs.  That is, it isn’t available to the typical VS user.

  3. LuisCa says:

    I fixed the link for the picture.

    And yes, the code analysis utility does not come will all editions of VS 2005. It comes with "Visual Studio Team Edition for Software Developers" and with "Visual Studio Team Suite".


    -Luis Cabrera

  4. This a very useful feature and nice to see it called out as it helps with the formation of better code.  That said, there seems to be an issue with using static analysis when you attempt to new up a RegistryState object (reference to Microsoft.WindowsMobile.Status required) in your code.  

    I filed a bug in November 2005 that has recently been changed to a status of closed (https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=117272). I know that this issue has not been fixed in VS2005 SP1 Beta1.  Any timeline on the issue getting fixed?

  5. And what dewelopers with Profesional version 🙁

  6. Mike Hudgell says:

    For professional users you can use FxCop.Addin <http://fxcopaddin.tigris.org/&gt; along with FxCop to achieve a similar solution to VSTS’s one….

  7. As posted by Windows Mobile in Redmond: "Did you know there is a managed code analysis tool in VS 2005?

Skip to main content