toaom

In our project the rule CA1822 triggers a lot. We don't want to make these static due to possible future inheritance scenarios. We don't want to mark them virtual yet as this is against the coding guidelines.

The last thing I want is to suppress this message for every function it might trigger.

The problem we're having is that TFS Checkin Policies will not allow you to disable a single rule in the project settings yet enforcing that the other code analysis rules have been checked. Is there a way I can disable this rule with a global suppression I can live with that. Or can we set this rule to "information" instead of error or warning

Warning 4 CA1822 : Microsoft.Performance : The 'this' parameter (or 'Me' in VB) of GebeurtenisDal.FillGebeurtenisWithIndicatorOnZaakID(GebeurtenisDS, Int32):Void is never used. Mark the member as static (or Shared in VB) or use 'this'/'Me' in the method body or at least one property accessor, if appropriate. D:\Projecten\xxxxx\xxxxx\Sources\xxxxx.xxxxxx.DAL\GebeurtenisDal.cs 100 xxx.xxx.DataAccessLayer



Re: Visual Studio Code Analysis and Code Metrics How to exclude certain rules from the TFS checkin policy

Ravs Kaur - MSFT

Hi,

You can disable a single rule from the Code Analysis Check In Policy. Ask your policy administrator to do the following:

- In the Team Explorer, right-click on Team Project -> Team Project Settings -> Source Control

- Click the Check In Tab

- Edit the Code Analysis Policy. This should bring up the Code Analysis Policy Editor.

- In the Code Analysis Policy Editor, expand Performance Rules, and uncheck CA1822

- Save the policy

In Whidbey, you cannot Migrate disabled rules to your project. So, on the developer's desktop, you can uncheck CA1822 in the Code Analysis Rules from the Code Analysis Property Pages and check in the changes to the project file. The policy should not complain of mismatched settings and CA1822 will not be run over your projects.

Hope this helps.

Thanks

Ravs





Re: Visual Studio Code Analysis and Code Metrics How to exclude certain rules from the TFS checkin policy

toaom

Thank you very much, this was exactly what I was looking for. Do you know if it will be possible to set certain violations to the level "information" instead of warning or error, now or in a future version

That would be helpful aswell. Some violations are more a guideline than a real error.




Re: Visual Studio Code Analysis and Code Metrics How to exclude certain rules from the TFS checkin policy

Ravs Kaur - MSFT

Currently there are no plans to set a rule severity to 'information'. Thanks for your suggestion though - I will pass it on to the team.