Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude viewmodel properties from CA1811

Using VS 2010/.Net 4.0, Code Analysis warning CA1811 (see below) is fired on all properties in a ViewModel even through they are used via XAML binding:

Warning CA1811 : Microsoft.Performance : 'BackupWindowViewModel.BackupCommand.get()' appears to have no upstream public or protected callers.

public ICommand BackupCommand { get { return _backupCommand; } }  <--- CA1811

<Button Content="Backup" Command="{Binding BackupCommand}" />

This is because Code Analysis (currently) does not parse XAML. My question is, is there a way to exclude all properties in all ViewModels (e.g. classes deriving from ViewModelBase) from CA1811? Having to suppress this warning on each individual property is a huge pain.

like image 261
Mr. Bungle Avatar asked Sep 30 '10 20:09

Mr. Bungle


1 Answers

  1. Open the project Properties page.
  2. Click the Build property page.
  3. In Errors and warnings section, modify the Suppress Warnings property: /nowarn:1811

http://msdn.microsoft.com/en-us/library/7f28x9z3%28v=VS.100%29.aspx

like image 182
Jake Berger Avatar answered Sep 24 '22 05:09

Jake Berger