Parameter modifier 'this' should be the first parameter of extension method
CodeRush Classic shows the Parameter modifier ‘this’ should be the first parameter of extension method code issue if the parameter with the this modifier is not the first parameter of an extension method.
#Fix
Place the parameter with the this modifier at the first position.
#Purpose
Highlights the member declarations, which would cause the Method has a parameter modifier ‘this’ which is not on the first parameter compilation error.
#Example
public static IEnumerable │GetValues(bool positiveOnly, this int[] intArray)
{
List<int> result = new List<int>();
foreach (int value in intArray)
if (!positiveOnly || value > 0)
result.Add(value);
return result;
}
Fix:
public static IEnumerable GetValues(this int[] intArray, bool positiveOnly)
{
List<int> result = new List<int>();
foreach (int value in intArray)
if (!positiveOnly || value > 0)
result.Add(value);
return result;
}