Reporter |
Image may be NSFW. Clik here to view. ![]() |
---|---|
Created | Jan 26, 2012 6:39:44 PM |
Updated | Jan 26, 2012 6:39:44 PM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Sergey Shkredov (serjic.shkredov) |
Subsystem | Refactoring |
Affected versions | 6.1.1 |
Fixed in build | No Fixed in build |
in the most recent 6.1.40.6, the code
would be converted (using "Convert into LINQ-Expression") to
If I am not missing anything, the test2 shoud be reducible the same way as the other four methods.
private int test1(IEnumerable<int> values) { int max = 0; foreach (int val in values) { if (val > max) max = val; } return max; } private int test2(IEnumerable<int> values) { int max = 0; foreach (int val in values) { if (val >= max) max = val; } return max; } private int test3(IEnumerable<int> values) { int max = 0; foreach (int val in values) { max = val > max ? val : max; } return max; } private int test4(IEnumerable<int> values) { int max = 0; foreach (int val in values) { max = val >= max ? val : max; } return max; } private int test5(IEnumerable<int> values) { int max = 0; foreach (int val in values) { max = Math.Max(max, val); } return max; }
would be converted (using "Convert into LINQ-Expression") to
private int test1(IEnumerable<int> values) { return values.Concat(new[] {0}).Max(); } private int test2(IEnumerable<int> values) { int max = 0; foreach (int val in values.Where(val => val >= max)) { max = val; } return max; } private int test3(IEnumerable<int> values) { return values.Concat(new[] {0}).Max(); } private int test4(IEnumerable<int> values) { return values.Concat(new[] {0}).Max(); } private int test5(IEnumerable<int> values) { return values.Concat(new[] {0}).Max(); }
If I am not missing anything, the test2 shoud be reducible the same way as the other four methods.