Reputation: 80
I'm getting false positives from the rule csharpsquid:S1172 - "Unused method parameters should be removed" for the following code:
public class ExampleConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
Both Convert and ConvertBack are part of the IMultiValueConverter implementation, and the rule states "virtual, override methods and interface implementations are ignored". However, in this case it fires for every parameter in both Convert and ConvertBack.
Is this a bug with the rule, or is it possible that I have set up something incorrectly?
Upvotes: 1
Views: 1664
Reputation: 6420
The C# plugin at the moment analysis each file individually, and with only mscorlib added as a reference. The IMultiValueConverter
is defined in PresentationFramework.dll, which is not added to the references to include in the compilation, therefore the compiler can't find it, and can't know that the two methods are part of that interface.
You won't face the same issue with SonarLint for Visual Studio, because that uses the all the references. (But this only works on the developer machine.) We are currently working on bringing this same accurate information to the SonarQube platform.
Upvotes: 3