Help
Overview
NStyle is a C# style compliance tool, allowing users to automatically check C# source code for proper formatting, freeing Code Reviewers to focus on application specific source code changes.
The goal of NStyle is to provide a highly configurable C# source code style compliance tool.
For organizations that want to impose a source code style guide, this tool enforces some general and more specific source code formatting and layout rules. Depending on your organization, your strictness on source code layout may be of varying importance. The rule set provided by this tool can be configured for your organization (future versions will include SDK documentation to allow custom rules to be incorporated into the tool.
| • | Release Readme |
| • | NStyle Components |
| • | NStyle Command-line Use |
| • | Visual Studio Integration |
| • | NStyle Rule Index |
| • | NStyle Example |
NStyle Components
NStyle consists of two main components, each installed on the developer's computer.
| • | NStyle.Console.exe - command-line tool to validate source code for style issues. |
| • | NStyle.ControlPad.exe - UI to configure an NStyle project and specific rules. |
The NStyle file is an XML configuration file containing all the information required for a source code projects compliance test. The file contains all Visual Studio C# project filenames that need to be checked. NStyle will processes the Visual C# project files each time to retrieve the proper set of source files to validate, there is no need to update the NStyle configuration unless you need to add or remove an entire Visual Studio project file.
The NStyle file also containing the configuration for each NStyle rule, whether active or not, as well as rule specific settings. Additional settings such as output file can also be found in the file.
The NStyle Console application will use the configuration file (see NStyle Command-line Use) as input for processing. Upon completion, an XML output file is generated with a predefined XML Style Sheet to help render the NStyle results in a more readable form. The default web browser will be launched to display the result set.
NStyle Command-line Use
The NStyle compliance tool supports the following command-line options
|
NStyle.Console.exe [--help] [--verbose] [--dump] <nstyle file> |
| --help | displays this command-line help information |
| --verbose | displays detailed information while processing |
| --dump | generate intermediate processing files |
| <nstyle file> | XML file containing NStyle processing information |
Visual Studio Integration
While the NStyle C# style guide compliance tool is a command-line utility, the tool can be integrated into your development environment.
|
1. |
In your Visual Studio Solution, add your NStyle project file (generated with the NStyle ConsolePad utility). |
|
2. |
Select your NStyle project and select "Open With..." from the popup-menu. |
|
3. |
Select the "Add..." command button. |
|
4. |
For "Program name", select "NStyle.Console.exe" in the |
|
5. |
For "Friendly name", enter "NStyle" |
|
6. |
Select the new "NStyle" entry and select the "Set as Default" command button. |
|
7. |
Double-click on the .NStyle file in the "Solution Explorer" to launch. |
NOTE: future versions of the tool will include a Visual Studio Add-in.
NStyle Example
A sample NStyle configuration is provided in the installation help folder (or available here).
A sample NStyle output file can be seen here.
The NStyle configuration file will be documented in future releases.