Skip to content
| Marketplace
Sign in
Visual Studio>Tools>AlmaStyleFix
AlmaStyleFix

AlmaStyleFix

Parisi_LabTSF

|
404 clicks
| (0) | Free
visual extension study for the analysis of the c # code style and the next automatic fix
Get Started

 

To ensure a proper maintenance of coding it is essential to write code in a “clean” and neat way. Throughout years, several global SW Factories have adopted a set of rules for coding, addressing clearness and legibility and making coding itself accessible to those developers who will have to maintain it throughout time.

The DotNet environment is no exception to the rule. CODEPLEX, the Open Source Community for DotNet programmers and developers, has published a valuable product, namely StyleCop, for the analysis of source code and the highlight of any style errors, as alerts and warning messages, suggesting programmers to solve the mistake before making their own work available and visible to other members of the Team.

StyleCop is an easy and effective product; in fact, no doubt a programme written according to suggested style rules is far much easy to read and effective.

StyleCop, however, has a great limit: the programme only notifies violations to style rules. Any correction action has to be taken by programmers themselves. What is frustrating is that violations often consist in trivialities, which could automatically be solved.

This is where the idea to implement a product capable of automatically perform rule fixing suggested by StyleCop comes from. To maximize product fruition, it has been designed as a Visual Studio extension, in order to have access to a set of strong mechanisms the development environment offers.

  

 

Setup

Product setup consists in an easy procedure, only taking a few seconds.

  1. Set up the entire StyleCop package, that is: both “Visual studio integration” and ”MSBuild integration files” (these latter are not installed by default) through the specific Setup file displaying the .msi extension, available at the following URL : StyleCop latest version
  2. Set up AlmaStyleFix by launching the specific Vsix-extension installer tool.
  3. If using Visual Studio, it is required to restart it, in order to use the programme.

  

 

Preparation to use AlmaStyleFix

AlmaStyleFix options

Once AlmaStyleFix has been setup, VisualStudio TOOLS menu will display AlmaStyleFix Settings options. Within the menu, a configuration window will be displayed (see below):

 

 

The various options are described below:

  • ·       Use version control: checking the specific assembly version is higher or equal to the current branch version (which can be worked out from the project path root). It is advised to use this check tool when using the branching and merging standard, assuming the branch name includes a standard-format name.Elsewhere this feature can be disabled.
  • ·       Automatically save before fix: saving the specific file before style check execution.It is a security measure making sure the file is saved before modifications are made.Note that, in case of problems, the previous version can be restored anytime, by simply using the “CTRL + Z” key combination.
  • ·       Use Highlighter: if activated, it highlights style errors, by changing the background of the specific code line. Once the mistake has been corrected, it is required to re-execute AlmaStyleFix, in order to get rid of the highlighter.
  • ·       Company: the Company name to type in, for file copyrighting.
  • ·       Author: the developer’s name (and e-mail address, optional) using the tool, for file copyrighting.
  • ·       Tool to change the highlighter tool color: enabling the customization of the highlighter according the personal preference: colors can be changed, by setting the R,G,B and transparency values.

It is advised to initially set up developer name and company, since this information will be uploaded at the start of any code file, in the copyright section, by AlmaStyleFix itself.

Style rule customization

It is possible to choose the set of style rules to use, via means of the option window panel provided by StyleCop. To access it, just right button click on the project and select “StyleCop Settings” from the drop-down menu, as shown in the picture below:

 

 

By doing this, rules to use can be selected/deselected. AlmaStyleFix will then automatically use the new pool of rules.

To save time, a pool of rules compatible with Italian comment has been attached to AlmaStyleFix. In order to install it, it is required to overwrite the “Settings.Stylecop” file of the “C:\Program Files (x86)\StyleCop 4.7” folder with the attached file.

Otherwise, each user can select the list of style rules to enable, project per project, by setting them from StyleCop Settings menu. It is always advised to link the setting file of own projects with the original one, that is: the one included in the set up folder, to make sure any modification is sent to any and all projects. In order to do so, it is requested to selected the option “Merge with the following settings File” and then select the “C:\Program Files (x86)\StyleCop 4.7\ Settings.Stylecop”, within the StyleCop options.

Right button of the mouse on the project -> StyleCopSettings-> Select the window “settings file” ->”merge with…”, as shown in the picture.

 

To access the program files folder, Visual Studio has to be run by an Administrator user (or with Admin rights).

 

 

Use of AlmaStyleFix

Before launching AlmaStyleFix, it is necessary to solve any and all compilation mistakes. Elsewhere, the programme will not be able to work and an error message will be displayed.

AlmaStyleFix will exclusively analyze the current document, which has to be a C# code file. To launch the programme, just click on the right button of the mouse on any part of the document; then select AlmaStyleFix from the drop-down menu, as shown in the screenshot:

 

As shown in the screenshot below, the programme automatically corrects what can automatically be corrected, whereas it notifies violations to style rules by using the highlight tool (if enabled).

 

By pointing the highlighted line with the mouse cursor, a suggestion in tooltip box will display the text of violation, so that programmers can learn how to intervene in order to solve the problem

In the example, a missing “summary” has been automatically generated, but it is necessary for programmers to manually intervene in order to insert some text.

In case of problems

Previous code can be restored anytime by using the combination of “CTRL + Z” keys. In case come StyleCop rules disable the recompile feature of code (indeed it may happen, but that cannot be blamed on me!), is it advised to disable the specific rules.

To find out which rule is responsible for any issue, StyleCop can be executed (right button of the mouse on project-> Run StyleCop): the related warning message, within which the rule coding generating the violation alert is present, will be displayed.

It is strongly advised to recompile code once the fixing has been performed, in order to avoid new issues.

  

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft