Code Style Enforcer 

General Information


Code Style Enforcer is a DXCore plug-in for Visual Studio 2005 / 2008 that checks the code against a configurable code standard and best practices. It is developed for C#, but some of the rules will also work for VB .NET, though not tested. 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.

• 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.

• 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

Visual Studio 2005 and Visual Studio 2008 are the only supported versions since Code Style Enforcer heavily relies on .NET Framework 2.0. The Express Editions of Visual Studio are not supported because DXCore does not support them.

Code Style Enforcer Screenshot

Latest Version


The latest and recommended version is the new 2.2.10, which works with DXCore version 3.0.8. Here is a list of some new features, changes and bug fixes since version 2.1.11.

New Features
• Settings file and default location for custom rules is changed to the user's documents folder. UAC should no longer be an issue.

• Rules are now only enforced for C# and VB projects/documents.

• Possible to activate/deactivate Code Style Enforcer for each individual project in a solution.

• Support for Visual Studio 2008.

• Optimizations of the code rule validation engine, which now utilizes background threads and incremental parsing.

• Report generation of code rule violations for all files in a solution. Different report templates are available, but it's also possible to add custom report templates. Report generation is accessed through the context menu of a solution.

• Code Style Enforcer activation dialog made more attractive.

• More nicer looking icons.

• New name rules added for enumeration, enumeration value, delegate, attribute and exception.

• New visibility rules added for enumeration, delegate, attribute and exception.

• Possible to specify a custom folder for global rules, in the Configurator application.

• Activation dialog in Visual Studio extended with support for specifying global and local rules.

• Selecting global rules automatically links the global rules in solution, without adding any physical files.

• Activation status, i.e. active or inactive, is stored in solution.

• Possible to specify a required suffix for each name rule.

• Experimental support for Visual Studio Codename "Orcas" (DXCore 2.2.2).

• Improved performance of the C# parser by approximately 30% (DXCore 2.2.2).

Bug Fixes
• Method parameters are now checked for violations again.

• Implicit and explicit cast operators no longer report invalid violations.

• Rules were not always loaded when opening a solution in Visual Studio 2008.

• Context menus in code editor and on solution item didn't show.

• Name refactoring didn't work in Visual Studio 2008.

• bool.TryParse(stringValue, out boolValue) no longer reports a name violation (fix in DXCore 3.0).

• Visual Studio crashed, due to a bug in DXCore, when attempting to parse a class with inheritance like: class ClassXXX : ClassXXX { }.

• Installation showed a non-informative error message, "Object reference not set to an instance of an object", when DXCore wasn't installed.

• Rule files no longer opened in code editor when activating CSE.

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 Developer Express.
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 CSE Configurator application found in the start menu. Configuration is also integrated with the DXCore options inside of 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

1. In Visual Studio, select the "DevExpress" menu.
2. Select "Options…"
3. The category called "Code Standard" contains all option pages for Code Style Enforcer.
4. The global rules are edited from here when global rules are linked to solution and the local rules are instead edited here when rules are added locally to solution.

Version History


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