The opinions expressed in these materials are my own and are not necessarily those of Microsoft.
Copyright © Microsoft Corporation. All rights reserved. Unless otherwise indicated, all source code provided is licensed under the Microsoft Public License (Ms-PL).
SKU: Premium, Ultimate
In vstipTool139 (“Static Code Analysis – Simple Code Analysis”) we scratched the surface of code analysis for a simple class. Now we will begin to delve deeper into the extensive set of predefined rules available out-of-the-box in Visual Studio. In these examples I will be using Visual Studio 2010 however most of the rules exist in Visual Studio 2008 as well. To see the list of the differences in rules read this article from the Code Analysis Team blog:
The biggest difference between Visual Studio 2008 and 2010 is the creation and management of rule sets which is why I have the version set to 2010 only. The new way to manage rules makes it very easy to work with existing rules in a multitude of ways. Also, I am limiting myself to managed code rules for these examples but the same techniques apply to unmanaged code rules as well. Without further ado, let’s explore some of the ways we can work with predefined rules.
First, create a new class library project in C# or VB then go to the project properties. Click on the Code Analysis tab inside the project properties. You should see the following:
The first choice you are faced with is which set of predefined rules to use. By default the Microsoft Minimum Recommended Rules will be applied however if you click on the dropdown list for the rule sets you will see many more options to choose from:
This table lays out the names and general purpose of each of the available managed predefined rule sets:
Microsoft All Rules
This rule set contains all rules. If you run this rule set, a large number of warnings might be reported. Use this rule set to get a comprehensive picture of all issues in your code. This approach can help you decide which of the more focused rule sets are most appropriate to run for your projects.
Microsoft Basic Correctness Rules
These rules focus on logic errors and common mistakes made in the usage of framework APIs. Include this rule set to expand on the list of warnings that the minimum recommended rules report.
Microsoft Basic Design Guideline Rules
These rules focus on enforcing best practices to make your code easy to understand and use. Include this rule set if your project includes library code or if you want to enforce best practices for easily maintainable code.
Microsoft Extended Correctness Rules
These rules expand on the basic correctness rules to maximize the number of logic and framework usage errors that are reported. These rules emphasize specific scenarios such as COM interoperability and mobile applications. Consider including this rule set if one of these scenarios applies to your project or to find additional problems in your project.
Microsoft Extended Design Guideline Rules
These rules expand on the basic design guideline rules to maximize the number of usability and maintainability issues that are reported. These rules emphasize naming guidelines. Consider including this rule set if your project includes library code or if you want to enforce the highest standards for writing maintainable code.
Microsoft Globalization Rules
These rules focus on problems that prevent data in your application from appearing correctly in different languages, locales, and cultures. Include this rule set if your application is localized, globalized or both.
Microsoft Minimum Recommended Rules
These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. You should include this rule set in any custom rule set that you create for your projects.
Microsoft Security Rules
This rule set contains all Microsoft security rules. Include this rule set to maximize the number of potential security issues that are reported.
Note: You can find this table in the documentation at http://msdn.microsoft.com/en-us/library/dd264925(VS.100).aspx
At a high level the rules deal with correctness, design, globalization, and security issues. Since we are creating a class library it might make sense for us to use the design guidelines based on the description. Pick the Microsoft Extended Design Guideline Rules for our project then click the Open button so we can explore the details:
NOTE: Keep one thing in mind as you explore these rules: there is no “one size fits all” solution. Your final rule set will almost always consist of several other rules that you feel are best for your needs.
We’ll get to the inner workings of this editor in a later post but, for now, focus on the ID column. Take note of the various categories we can expand to get details. Below is a list of these categories and what they represent:
Warnings that support correct library design as specified by the .NET Framework Design Guidelines.
Warnings that support world-ready libraries and applications.
Warnings that support interaction with COM clients.
Warnings that support library and application maintenance.
Warnings that support efficient power usage.
Warnings that support adherence to the naming conventions of the .NET Framework Design Guidelines.
Warnings that support high-performance libraries and applications.
Warnings that support portability across different platforms.
Warnings that support library and application reliability, such as correct memory and thread usage.
Warnings that support safer libraries and applications.
Warnings that support appropriate usage of the .NET Framework.
Note: You can find this table in the documentation at http://msdn.microsoft.com/en-us/library/ee1hzekz.aspx
The number of rules you deal with in each category depends on the rule set you have chosen. For example, the extended design rule set has about 60 design rules, 2 globalization rules, and 7 interoperability rules among the other rules in this set:
By now you have no doubt noticed the warning just below the toolbar in this editor. You are just exploring the rules for now but when we modify the rules in a later tip you will have to save your changes to a new rule set file. Don’t be intimidated by rule set files, they are just XML files. Here is a piece of the extended design rule set in Notepad:
Back in our rule set editor, expand the Microsoft.Design category and select rule CA1044:
The first time you select a rule, you will be presented with this choice at the bottom of the rule set editor:
I suggest leaving the default settings and then click the OK button. When you do, you will then see the help entry for the rule you are currently looking at:
At this point we have gone from understanding the basic function of the predefined rule sets to understanding the categories of the rules in a set to understanding individual rules. From here you can explore the different rule sets and each of the rules in those sets to determine what rules may be interesting to you going forward. We will learn more about navigating these rule sets in the next tip.
At long last it is with great pride that I can officially announce the availability our new book! After a year of work and a few interesting speed bumps along the way the book is now in stores world-wide. If you want the best price that I have seen so far, I suggest you go to Amazon:
If you get a copy of the book, Sara and I would love to hear what you think about it and any improvements you would like to see in the next revision. You can email me at firstname.lastname@example.org with your comments / suggestions / etc.. Also, if you get a chance, please make sure to give a review on Amazon and/or the O’Reilly web site so others will know if they should buy the book or not.
For those who aren’t regular readers of this blog, here is the basic information from the main O’Reilly book site:
Take a detailed look into Visual Studio—and learn practical techniques to help you work more efficiently. This fully revised and expanded version of Visual Studio Tips: 251 Ways to Improve Your Productivity includes a comprehensive collection of tips and shortcuts for working with the code editor, visual designers, searches, debugger, and other features in Visual Studio 2005, 2008, and 2010.
Expert advice to help you work smarter and increase your productivity with Visual Studio.
Take a detailed look into Visual Studio—and learn practical techniques to help you work more efficiently. This fully revised and expanded version of Visual Studio Tips: 251 Ways to Improve Your Productivity includes a comprehensive collection of tips and shortcuts for working with the code editor, visual designers, searches, debugger, and other features in Visual Studio 2005, 2008, and 2010. You'll gain valuable insights for using this IDE—no matter what your experience level.
Discover how to:
I thought it would be appropriate to list the acknowledgements for the book here again to thank those who had an impact on our lives and on the book:
Jane and Louie Smolensky / Beulah Bourgeois / Annabelle Fayard / Helen Naboulsi / Russell Chandler—Our immediate friends and family.
Russell Jones and Adam Zaremba—Editors at O’Reilly Media, who herded the cats to make this book happen.
Kevin Stevens—Who came up with the name of the book and was instrumental in the technical review process.
Paul Millsaps and Bill Needels—For doing some of the technical review for the book.
Sean Laberee—Senior Program Manager Lead at Microsoft who helped both Sara and me get started with Tips and Tricks.
Dustin Campbell—Program Manager at Microsoft who continues to be a constant source of information when I get stuck on a feature or concept.
Brittany Behrens—Program Manager at Microsoft who helped me during those first tenuous days after I took over Sara’s work.
Matt Manela—for writing the content for the Snippet Designer extension.
Andrew Steele—for writing the content for the Productivity Power Tools extension.
Jim Christopher—for writing the content for both the GhostDoc and the StudioShell extensions.
Terry Leeper—Principal Architect, Windows C++ Team, my main contact with the C++ folks and a good friend that has helped me resolve questions about features since I started doing the tips.
Lisa Feigenbaum and Beth Massi—Program Managers at Microsoft who constantly provided guidance and support as the content of the book evolved.
Brian Moore—Director, DPE Central Region, for providing support and being a great manager.
Clint Edmonson—Senior Architect Evangelist at Microsoft who I have toured with throughout the country delivering Visual Studio talks to thousands of people.
Phil Wheat—My best friend at Microsoft and a constant source of information. Phil is easily the smartest person I know.
Jared Bienz, Mike Azocar—Very good friends who have been great to bounce ideas around as I worked on the book.
Rob Bagby, Mike Benkovich, John Weston, Keith Combs—My old Microsoft Across America buddies.
Finally, Sara Ford wishes to thank Dr. Terrance Delaney and Dr. Michael McMurray for fixing her chronic shin splints during the course of writing this book.
Windows: CTRL + Double Click on Title Bar Menu: Window | Dock As Tabbed Document Command: Window.DockAsTabbedDocument
SKU: Professional, Premium, Ultimate Versions: 2010, Visual Studio 11 Developer Preview Code: vstipEnv0065
In Visual Studio 2010 we introduced the ability to take document windows outside the IDE:
However, the old trick of double-clicking on the Title Bar to dock the window back into the tab well doesn’t work anymore. It turns out that CTRL + Double-Click is the new shortcut to dock document windows back into the IDE:
If you have installed the Productivity Power Tools (http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef) or have Visual Studio 11 Developer Preview then you have floating tab wells:
You can CTRL + Double-Click on the window’s Title Bar to dock all the tabs in the external tab well.
The strange part comes when you have multiple tabs in an external tab well. If CTRL + Double-Click on an individual tab in the external tab well when there is more than one tab it creates a new tab well with only one tab in it. When you CTRL + Double-Click on a tab that is the only one in the current tab well then it will dock it. Not sure if this is intentional behavior or a bug.
My friend, Jon Box, asked me to let all the country music fans out there know about this great contest that is going on for the Country Music Awards. Here is what he has to say about it:
Rascal Flatts, Jason Aldean, and Ronnie Dunn have different prize packages just waiting for you. Go to these links and follow the registration instructions. You’ll need IE9 and Windows 7, and the contest payoff could be big for the country music fan. Each artist has their own contest and they have different COOL prizes. They do each offer CMA Music Fest 4 Day passes, which makes this WAY COOL!!!
And 4 nights at LP Field plus these other prizes, it’s a country music fan’s dream event. If you don’t know, CMA Music Fest is like no other music event. During the day, you can visit Fan Fair Hall to meet artists, as well as see artists perform at music stages around downtown Nashville (just check out the Riverfront Park schedule – awesome by itself). Then at night, we head to LP Field and see some of the hottest names in country music (6 mini-concerts each night on the schedule). And as the CMA Music Fest veterans know, 4 day pass holders get special benefits at LP Field like STAGE-FRONT access in the Fan Photo Line. Nothing like a stroll right in front of a big act blowing out the stadium.
These contests will be done through an IE9 feature called “site pinning”. The instructions on the contest links will tell you exactly what to do to get started. But, basically, after providing your Facebook login, there will be an image to drag to your taskbar (this is the pinning), which will put a button from your artist on your taskbar. And then daily right click, and select “Enter Pin To Win Contest”.
So if you are a country music fan here is your chance to attend the CMA Music Fest
I just got an update on the expected date for the book and thought I would let you all know. Right now it appears that, due to all the formatting that needs to be done, the date for release is late July / early August. I went a few rounds with the editors to get this date pushed earlier but they convinced me there is no way to get the book out sooner without sacrificing the quality of the work. I know many of you are waiting for the release and I, too, am just waiting to get it out there so we can get this into people’s hands.
For those on Facebook, I’ve created a page for the new book that I will post info and polls, etc… on:
On a semi-related note, now that the book is completed, I’ll be taking the month of June and early July off to recharge. I’ll pick back up again in mid July and hit the ground running with more tips and information on the new book (of course). If any breaking news comes up between now and then I’ll post it and I will most likely post other miscellaneous things as well concerning conferences, contests, etc… that are coming up just so the blog isn’t completely dark during my time off.
Folks I just wanted to call it out since the book doesn’t really emphasize it as much as I would like. The appendix is basically a second book that goes with the first. I took the entire body of work and divided it into part that go to print and parts that get put in the appendix area. If you only read the book you are only getting half the content so make sure you do the following:
I know I normally stick to Visual Studio topics but thought I would throw in some Windows 8 information since that is the platform we will be using going forward. I’ll mix in Win 8 information through the product lifecycle and pull the covers off interesting pieces that we may want to dig into. With that said, Steven Sinofsky has been blogging on the new features coming up in the new OS. You can find his posts at the Building Windows 8 blog found here:
Keep an eye out for more information going forward…
Hey folks! Well Visual Studio 11 Developer Preview is here and the Visual Studio team has asked me to write about some of the cool new features coming in the next release. My first post, on the new VB Call Hierarchy, can be found at the Visual Basic Team blog here:
I’ll be writing more about new features going forward and will either post it here or have a post, like this one, that will show you which VS Team blog you can find my latest work at. Enjoy!
[NOTE: This post has been depricated you can find the new post here:
I’m very excited about the new Quick Launch feature! You can catch my latest post on this feature on the Visual Studio Team Blog here:
I’ll be posting some of my material to the various team blogs and, of course, this blog throughout the VS 11 cycle but will always have pointers to the information from here for reference.
Just came across these the other day and wanted to share below is the information verbatim from http://msdn.microsoft.com/en-us/library/vstudio/ee889983(v=vs.120).aspx
Welcome to the technical articles for Application Lifecycle Management! These technical articles provide additional resources for you to use when supporting your development efforts with Team Foundation Server. Some provide in-depth technical information about unique scenarios that involve Visual Studio Application Lifecycle Management. Others provide insights into development processes and philosophies from industry experts that you might want to consider when developing your software or working as a team on a software project. These articles represent the viewpoints, opinions, and experience of their individual authors.
Agile Principles and Values, by Jeff Sutherland. Jeff Sutherland provides an overview of the Agile principles as defined in the Manifesto for Agile Software Development.
Ten Year Agile Retrospective: How We Can Improve in the Next Ten Years by Jeff Sutherland. Ten years after the publication of the Agile Manifesto, Jeff Sutherland describes the successes of Agile and pinpoints four key success factors for the next ten years.
Done and Undone by Ken Schwaber and David Starr. Delivering a done increment is critical to being successful with agile software development. Using both real-world and theoretical examples, the authors demonstrate the difference between perception of "done" and the reality of "done," and how that affects the success of a project. Using these examples, the authors go on to demonstrate tools and strategies that can help teams start with a definition of done that makes sense for them, and methods to help teams communicate dependencies, status, and the meaning of "done."
Building and Managing the Product Backlog by Mitch Lacey. A good product backlog is at the heart of any well-functioning agile team. In this article, Mitch Lacey explains the importance of a product backlog, describes what makes a good backlog, and provides some best practices for creating and maintaining your backlog.
Prioritization by Mitch Lacey. In this article, Mitch Lacey discusses three methods that have proven very beneficial for many Agile teams: the Kano Model of Customer Satisfaction, a series of Innovation Games by Luke Hohmann, and Karl Weigers’ Relative Weighting model. He describes how any of these methods can help you move from rough prioritization of your backlog to a precise ordering that satisfactorily weighs risk, importance, and customer satisfaction.
Estimating by Mitch Lacey. Mitch Lacey discusses the difficulty surrounding software project estimation, and provides tips and tricks for using two agile software estimation techniques when teams are estimating projects.
Sprint Planning by Mitch Lacey. Sprint planning does not need to be challenging. In this article, the author provides examples and strategies for keeping sprint planning focused and effective, and detail potential solutions to common problems teams encounter when planning a sprint.
Effective Sprint Retrospectives by David Starr. Going beyond techniques, this article offers ways to maintain and improve the practice and results of Retrospectives.
Distributed Scrum by David Starr. Distributed teams often struggle with consistent, timely, and effective communication. In this article, David Starr explains how Scrum offers a container in which different types of distributed teams can improve and succeed.
Enterprise Agile: Using TFS to support portfolio backlogs across multiple teams by Gregg Boer. Learn how TFS can be configured to support a portfolio of backlogs which provides automatic roll-up and management insight into work across multiple teams.
Lean Software Development by David J. Anderson. David J. Anderson describes Lean Software Development, its history, and how it can be used by software development project teams.
CMMI Principles and Values by David J. Anderson. The concept that an organization can be appraised at a particular maturity level and that this is an indicator of capability to deliver reliable work to the government is a matter of ongoing debate. In this article, David J. Anderson makes a case for Capability Maturity Model Integration (CMMI) and describes how it provides valuable insights for managers, process engineers and all external stakeholders including customers, investors, governance bodies and auditors.
The Lean of Scrum by David Starr. In this article, learn about the inherent Lean qualities of the Scrum framework along with various ways to help Scrum Teams improve using Lean Thinking.
Microsoft Solutions Framework (MSF) Overview . In this article, learn about the Microsoft Solutions Framework (MSF), an adaptable approach for successfully delivering technology solutions faster, with fewer people and less risk, while enabling higher quality results.
Application Analytics: What Every Developer Should Know by Sebastian Holst. In this article, Sebastian Holst discusses the objectives and advantages of application analytics.
Exploratory Software Testing by James Whittaker. In this article, an excerpt from his book Exploratory Software Testing: Tips, tricks, tours and techniques to guide test design, James Whittaker discusses goals, advantages, and approaches to exploratory software testing.