The analyzer will suggest more code fixes to error CS1501 about adding missing parameters.
The initial rules are:
- When there's only one reference to the method, it will suggest adding the parameter (in the call order).
- If there are two or more references to the method, it will suggest adding the parameter optionally with the default value of the type (adding the optional parameter at the end of the parameters list). If the method already exists, just change the order.
Rule 1
Case 1
Before:
static void Main(string[] args)
{
A(5);
}
static void A()
{
}
After:
static void Main(string[] args)
{
A(5);
}
static void A(int a)
{
}
Case 2
Before:
static void Main(string[] args)
{
A("", 5);
}
static void A(int a)
{
}
After:
static void Main(string[] args)
{
A("", 5);
}
static void A(string b, int a)
{
}
Rule 2
Case 1
Before:
static void Main(string[] args)
{
A();
A(5);
}
static void A()
{
}
After:
static void Main(string[] args)
{
A();
A(5);
}
static void A(int a = 0)
{
}
Case 2
Before:
static void Main(string[] args)
{
A(5);
A("", 5);
}
static void A(int a)
{
}
After:
static void Main(string[] args)
{
A(5);
A(5, "");
}
static void A(int a, string b = null)
{
}
Case 3
Before:
static void Main(string[] args)
{
A(5);
A("", 5);
}
static void A(int a)
{
}
static void A(int a, string b)
{
}
After:
static void Main(string[] args)
{
A(5);
A(5, "");
}
static void A(int a)
{
}
static void A(int a, string b)
{
}
Severity: Hidden
Category: Refactoring
The analyzer will suggest more code fixes to error CS1501 about adding missing parameters.
The initial rules are:
Rule 1
Case 1
Before:
After:
Case 2
Before:
After:
Rule 2
Case 1
Before:
After:
Case 2
Before:
After:
Case 3
Before:
After:
Severity: Hidden
Category: Refactoring