Coding guidelines are very useful and should be enforced wherever possible. The free tool AIT Apply Company Policy (ACP), which we already presented in another blog entry, can help here. But there might be some guidelines or rules that should be applied to only some projects or to all except some projects. This is now possible with the new version of AIT Apply Company Policy, which is available in the download section.
For example one could create an ACP package that will be applied to all projects, but for all test projects the documentation should not be created. Then the respective section in the CompanyPolicy.config could look like this:
<Documentation exclude="*.Test"> <Configuration Name="Debug" enabled="true" /> <Configuration Name="Release" enabled="true" /> <Configuration Name="Staging" enabled="true" /> </Documentation>
The exclude attribute determines that in all projects ending with “.Test” the documentation will not be created.
In another scenario one could create an ACP package which should be applied only to test projects, e.g. specific rules for the static code analysis, and one has to make sure that this package can really be applied only to test projects. This is possible using the following entry:
<StaticCodeAnalysis includeOnly="*.Test"> <Configuration Name="Debug" enabled="true" ruleSet="AIT.ruleset" /> <Configuration Name="Release" enabled="true" ruleSet="AIT.ruleset" /> <Configuration Name="Staging" enabled="true" ruleSet="AIT.ruleset"/> </StaticCodeAnalysis>
Here the includeOnly attribute defines that the rules for the static code analysis is applied only to projects ending with “.Test”.
Furthermore it is possible to combine both of these attributes. This way, one can apply rules e.g. only to projects whose name contains “Infrastructure” but does not end with “.Test”.