Code Style Enforcer 

General Information

Code Style Enforcer 3.5 and above will only work in Visual Studio 2010, since it is utilizing the new editor extension capabilities introduced in Visual Studio 2010. Code Style Enforcer checks the code against a configurable code standard and best practices. It is developed for C#, but some of the rules will also be applicable VB.NET. The code standard is currently configurable with the following rules:

• Name rules, where it is possible to have different rules for different members, i.e. fields, constants, variables, methods, properties and so on. It is also possible to add overrides to code types, i.e. specifying different name rules for code types with specific modifiers (keywords) or visibility.

• Visibility rules, where you can specify the visibility that is valid for different members. It is also possible to specify that the visibility has to be specified explicitly. It is also possible to add overrides to code types, i.e. specifying different visibility rules for code types with specific modifiers (keywords).

• Implementation rules, where it is possible to specify that interface implementations are to be made explicitly or implicitly.

The default rules are based on the C# Coding Standard from IDesign. It is the most complete code standard available and it is free to download.

Supported Visual Studio Versions

Code Style Enforcer 3.5 and above is a Visual Studio 2010 extension and the previous version 2.0+ is a plug-in for Visual Studio 2005 and Visual Studio 2008. The Express Editions of Visual Studio are not supported because DXCore, which is used for source code parsing, does not support them.

Code Style Enforcer Screenshot

Latest Version

The latest and recommended version is the new 3.5.17 for Visual Studio 2010, which requires DXCore v2011 vol 2.7 (11.2.7) or later.

New Features

• A redesigned and more flexible rule system supporting more granular name and visiblity rules based on not only the code type, but also on modifiers and visibility.

• The separate rule configurator application has been removed and both local and global rule configurations can now be made within Visual Studio instead (Tools menu --> Code Style Enforcer). This also solves the problem where the configurator application stopped working for each new release of DXCore.

• New UI for configuring code rules, utilizing grids to get a uniform view for all different rule types while also making the configuration easier to extend for a future and more flexible rule system.

• Code rules, for a specific solution, are now configurable from within Visual Studio 2010, through Code Style Enforcer -> Properties from the solution node's context menu in the Solution Explorer.

• Code Style Enforcer Configurator converted to a WPF application using the new rule configuration pages.

• Possible to configure different interface implementation rules for properties, methods and events.

• Activation/Deactivation of Code Style Enforcer can now be done for the complete solution and for specific projects. The "Active" command is available from the context menu when right-clicking on the solution node or a project node in the Solution Explorer.

• Generate reports functionality added for generating an XML file containing all rule violations for the complete solution. Different XSL style sheets can then be used for a proper presentation of the data. The "Generate Report..." command is available from the context menu when right-clicking on the solution node in the Solution Explorer.

• New improved activation dialog in WPF.

• Tooltips added with descriptions of the code rule violations (presented when hovering over a violation).

• Smarttags added for correcting name and visibility rule violations (activated by putting the cursor on a violation).

• Support for Visual Studio 2010.

Bug Fixes

• Code rules can now be saved upon change even if rule files have become readonly, e.g. by using TFS in offline mode.

• Probable prefix, in a name rule violation, was not removed from name when automatically suggesting a new name.

• Loading the default rules did not work when the local rules were the same as the global rules, i.e. the global rules were linked into the solution.

• Code Style Enforcer Configurator could crash when trying to save rules to a read-only location.

• The wrong violation description was presented for name rules where no prefix was allowed.

Breaking Changes

• Due to changes in the code rule definitions, any old customized code rules will get backed up and the new default rules will instead be loaded, when opening the Global Code Rules Options dialog in Visual Studio or a previously Code Style Enforcer activated solution.

Download Code Style Enforcer

Installation Instructions

1. If running Windows Vista, make sure User Access Control is turned off.
2. Make sure you do not have any instances of Visual Studio running.
3. Uninstall any previous versions of Code Style Enforcer from the Control Panel.
4. Download and install the latest version of DXCore, from DevExpress.
5. Download the latest Code Style Enforcer plug-in. Extract the zip file and execute the Setup.exe and follow the instructions.
6. Start Visual Studio, write some code and you will most probably see some red lines below some of your code statements.

Configuration Instructions

Configuration of the code standard for Code Style Enforcer can be done from the Code Style Enforcer Configurator application found in the start menu. Configuration is also integrated within Visual Studio.

Global Configurator

1. In the start menu, select "Code Style Enforcer" and "Configurator".
2. Select where the global rules are to be located, e.g. a shared folder under source control, since the rules will be linked to a solution from here when selecting "Use Global Rules" in Visual Studio.
3. Configure the global rules that are most common for your solutions.

Option Pages in Visual Studio

1. In the beta version, code rule changes are limited to the Code Style Enforcer Configurator application or through manual editing of the XML rule files.

Version History

Code Style Enforcer 3.0.71 (DXCore 10.2.9)

Code Style Enforcer 3.0.51 (DXCore 10.2.5)

Code Style Enforcer 3.0.43 (DXCore 10.2.3)

Code Style Enforcer 3.0.32 Beta (DXCore 10.1.7)

Code Style Enforcer 3.0.17 Beta (DXCore 10.1.4)

Code Style Enforcer 3.0.13 Beta (DXCore 10.1.4)

Code Style Enforcer 3.0.7 Beta (DXCore 10.1.4)

Code Style Enforcer 2.2.34 (DXCore 9.3.4)

Code Style Enforcer 2.2.10 (DXCore 9.3.3)

Code Style Enforcer 2.2.1 (DXCore 3.0.8)

Code Style Enforcer 2.1.32 (DXCore 2.5.8)

Code Style Enforcer 2.1.29 (DXCore 2.2.2)

Code Style Enforcer 2.1.25 (DXCore 2.2.2)

Code Style Enforcer 2.1.22 (DXCore 2.2.2)

Code Style Enforcer 2.1.11 Beta (DXCore 2.2.2)

Code Style Enforcer 2.1.10 Beta (DXCore 2.2.2)

Code Style Enforcer 2.1.1 Beta (DXCore 2.1.3)

Code Style Enforcer 2.1.0 Beta

Code Style Enforcer 2.0.1