StyleCop 4.2 MSBuild Integration

This article explains how to integrate the StyleCop tool into an MSBuild based build environment. This type of integration will cause the tool to run automatically whenever the code is built, and StyleCop violations will show up alongside compiler errors in the build output. It is possible to set up the build integration so that StyleCop violations will…

3

Configuring Hungarian Notation Rules

By default, Microsoft StyleCop does not allow variable or field names to include Hungarian notation. This is enforced by rule SA1305, FieldNamesMustNotUseHungarianNotation. The implementation of this rule is rather straightforward, assuming that any field or variable name which begins with one or two lower-case letters and is followed by an upper-case letter is guilty of…

0

Configuring Results Cache Settings

Each time StyleCop is run, it will cache the results of the analysis onto the disk. The next time StyleCop is run on the same project or file, the tool will determine whether any changes have occured within the file since the last analysis. If not, the previous results are read from the cache. For larger files and projects, this can…

0

Configuring File Header Company and Copyright

It is possible to control the company name and copyright text that is required within the file header at the top of every C# source file. A typical file header looks like the following: //———————————————————————– // <copyright file=”Widget.cs” company=”Sprocket Enterprises”> //     Copyright (c) Sprocket Enterprises. All rights reserved. // </copyright> //———————————————————————–   By default, StyleCop will…

0

Sharing StyleCop Settings Across Projects

By default, StyleCop configuration settings are applied on a project by project basis. In a standard installation, each project folder will contain a Settings.SourceAnalysis file, describing the settings for this project. In cases where the default settings are used, there may be no settings file for the project. It is possible, however, to create StyleCop settings files…

0

Enabling or Disabling StyleCop Rules

It is possible to enable or disable individual StyleCop rules at the project level. First, read this article to learn how to bring up the settings dialog for a particular project. Bring up the settings dialog for a particular project, and select the Rules tab, as shown below: A rule can be enabled or disabled by…

0

Managing StyleCop Project Settings

Microsoft StyleCop is configurable at the project level, allowing different projects in the same solution to use different StyleCop settings. It is also possible to share StyleCop settings between multiple projects, as described here. To edit the settings for a particular project, right-click on the project node in Visual Studio and select StyleCop Settings, as shown below: This brings up…

0

StyleCop Settings

The following pages describe how to manage settings within the StyleCop tool.Changing the settings for a projectSharing settings files across multiple projects

0

Setting Up StyleCop MSBuild Integration

This article explains how to integrate the StyleCop tool into an MSBuild based build environment, for StyleCop 4.3 and above. If you are using SourceAnalysis 4.2, please see the following article: http://blogs.msdn.com/sourceanalysis/pages/stylecop-4-2-msbuild-integration.aspx. MSBuild integration will cause the tool to run automatically whenever the code is built, and StyleCop violations will show up alongside compiler errors in the build…

30