Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed odd naming suggestions #59674

Merged
merged 9 commits into from
Feb 27, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class C
{
void M()
{
var v = new { P = new { Type = this.GetType(), V = this.ToString() } };
var v = new { Value = new { Type = this.GetType(), V = this.ToString() } };
}
}");
}
Expand All @@ -108,7 +108,7 @@ class C
{
void M()
{
var v = new { P = new { Type = this.GetType(), V = this.ToString() } };
var v = new { Value = new { Type = this.GetType(), V = this.ToString() } };
}
}");
}
Expand All @@ -130,7 +130,7 @@ class C
{
void M()
{
var v = new { P = new { Type = this.GetType(), Type1 = this.GetType() } };
var v = new { Value = new { Type = this.GetType(), Type1 = this.GetType() } };
}
}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void M()
@"
class C
{
public C(object p, int i) { }
public C(object value, int i) { }
}

class D
Expand Down Expand Up @@ -1068,7 +1068,6 @@ void M2()
M1(1, 2);
}
}");
//Should fix to: void M1<T>(T arg, T v) { }
}

[WorkItem(21446, "https://github.com/dotnet/roslyn/issues/21446")]
Expand Down Expand Up @@ -1199,7 +1198,7 @@ void M2()
@"
class C1
{
void M1((int, int) t1, (int, string) p)
void M1((int, int) t1, (int, string) value)
{
}
void M2()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ static void Main(string[] args)
{
System.Collections.Generic.IEnumerable<int> enumerable()
{
var vs1 = new int[] { 1, 2 };
var vs = new int[] { 3, 4 };
foreach (var num in vs1)
var ints1 = new int[] { 1, 2 };
var ints = new int[] { 3, 4 };
foreach (var num in ints1)
{
foreach (var a in new int[] { 5, 6 })
{
foreach (var x1 in vs)
foreach (var x1 in ints)
{
if (object.Equals(num, x1))
{
Expand Down Expand Up @@ -221,18 +221,18 @@ static void Main(string[] args)
{
System.Collections.Generic.IEnumerable<int> enumerable()
{
var vs2 = new int[] { 1, 2 };
var vs1 = new int[] { 3, 4 };
var vs = new int[] { 7, 8 };
foreach (var num in vs2)
var ints2 = new int[] { 1, 2 };
var ints1 = new int[] { 3, 4 };
var ints = new int[] { 7, 8 };
foreach (var num in ints2)
{
foreach (var a in new int[] { 5, 6 })
{
foreach (var x1 in vs1)
foreach (var x1 in ints1)
{
if (object.Equals(num, x1))
{
foreach (var x2 in vs)
foreach (var x2 in ints)
{
if (object.Equals(num, x2))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class C
{
void M(Action action)
{
Action {|Rename:p|} = () => { var x[||] = y; };
M(p);
Action {|Rename:value|} = () => { var x[||] = y; };
M(value);
}
}");
}
Expand Down Expand Up @@ -1450,8 +1450,8 @@ void Main()
{
void Main()
{
var {|Rename:p|} = new { A = 0 };
var a = p;
var {|Rename:value|} = new { A = 0 };
var a = value;
}
}");
}
Expand All @@ -1474,8 +1474,8 @@ static void Main(string[] args)
static void Main(string[] args)
{
int[] a = null;
var {|Rename:vs|} = a = new[] { 1, 2, 3 };
int[] temp = checked(vs);
var {|Rename:ints|} = a = new[] { 1, 2, 3 };
int[] temp = checked(ints);
}
}",
options: ImplicitTypingEverywhere());
Expand Down Expand Up @@ -1516,8 +1516,8 @@ void Main()
{
void Main()
{
var {|Rename:p|} = new { X = 1 };
WriteLine(p);
var {|Rename:value|} = new { X = 1 };
WriteLine(value);
}
}");
}
Expand Down Expand Up @@ -2567,8 +2567,8 @@ static void Main(string[] args)
{
Func<int, Func<int, int>> f = x =>
{
Func<int, int> {|Rename:p|} = y => y + 1;
return p;
Func<int, int> {|Rename:value|} = y => y + 1;
return value;
};
}
}");
Expand Down Expand Up @@ -2596,8 +2596,8 @@ static void Main(string[] args)
{
Func<int, Func<int, int>> f = x =>
{
Func<int, int> {|Rename:p|} = y => x + 1;
return p;
Func<int, int> {|Rename:value|} = y => x + 1;
return value;
};
}
}");
Expand Down Expand Up @@ -4964,8 +4964,8 @@ public async Task Tuple_TuplesDisabled()
var expected =
@"class C
{
private static readonly (int, string) {|Rename:p|} = (1, ""hello"");
var i = p.ToString();
private static readonly (int, string) {|Rename:value|} = (1, ""hello"");
var i = value.ToString();
}";

await TestAsync(code, expected, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp6));
Expand Down Expand Up @@ -5003,8 +5003,8 @@ public async Task Tuple_IntroduceConstant()
var expected =
@"class C
{
private static readonly (int, string) {|Rename:p|} = (1, ""hello"");
var i = p.ToString();
private static readonly (int, string) {|Rename:value|} = (1, ""hello"");
var i = value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected);
Expand All @@ -5022,8 +5022,8 @@ public async Task TupleWithNames_IntroduceConstant()
var expected =
@"class C
{
private static readonly (int a, string b) {|Rename:p|} = (a: 1, b: ""hello"");
var i = p.ToString();
private static readonly (int a, string b) {|Rename:value|} = (a: 1, b: ""hello"");
var i = value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected);
Expand All @@ -5041,8 +5041,8 @@ public async Task Tuple_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int, string) {|Rename:p|} = (1, ""hello"");
var i = p.ToString() + p.ToString();
private static readonly (int, string) {|Rename:value|} = (1, ""hello"");
var i = value.ToString() + value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand All @@ -5060,8 +5060,8 @@ public async Task TupleWithNames_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int a, string b) {|Rename:p|} = (a: 1, b: ""hello"");
var i = p.ToString() + p.ToString();
private static readonly (int a, string b) {|Rename:value|} = (a: 1, b: ""hello"");
var i = value.ToString() + value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand All @@ -5079,8 +5079,8 @@ public async Task TupleWithDifferentNames_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int a, string b) {|Rename:p|} = (a: 1, b: ""hello"");
var i = p.ToString() + (c: 1, d: ""hello"").ToString();
private static readonly (int a, string b) {|Rename:value|} = (a: 1, b: ""hello"");
var i = value.ToString() + (c: 1, d: ""hello"").ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand All @@ -5098,8 +5098,8 @@ public async Task TupleWithOneName_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int a, string) {|Rename:p|} = (a: 1, ""hello"");
var i = p.ToString() + p.ToString();
private static readonly (int a, string) {|Rename:value|} = (a: 1, ""hello"");
var i = value.ToString() + value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand Down Expand Up @@ -6074,8 +6074,8 @@ class C
byte[] getArray() => null;
void test()
{
byte[] {|Rename:vs|} = getArray();
var goo = vs[0];
byte[] {|Rename:bytes|} = getArray();
var goo = bytes[0];
}
}");
}
Expand Down
Loading