Reporter |
![]() |
---|---|
Created | Feb 27, 2012 3:30:06 PM |
Updated | Feb 28, 2012 12:41:11 PM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Alexey Kuptsov (alexey.kuptsov) |
Subsystem | LINQ Tools |
Affected versions | 6.1 |
Fixed in build | No Fixed in build |
Hi.
Using "Loop can be converted into LINQ-expression" feature in a loop that calls a method with two or more parameters where one of the parameters is passed by reference and the other is not creates a LINQ expression that doesn't compile.
The following example demonstrates this (It logically doesn't have any sense at all - I stumbled upon this issue in a more complex scenario but I can't provide the code).
After conversion there is a compilation error:
Cannot pass the range variable 'itemAsString' as an out or ref parameter
I'm using R# version 6.1.37.86.
The sample application is attached.
Using "Loop can be converted into LINQ-expression" feature in a loop that calls a method with two or more parameters where one of the parameters is passed by reference and the other is not creates a LINQ expression that doesn't compile.
The following example demonstrates this (It logically doesn't have any sense at all - I stumbled upon this issue in a more complex scenario but I can't provide the code).
Before
class Program { static void Main() { var list = Enumerable.Range(0, 10); var result = new List<string>(); foreach(var item in list) { var itemAsString = item.ToString(CultureInfo.InvariantCulture); result.Add(SomeMethod(ref itemAsString, item)); } } static string SomeMethod(ref string param, int whatever) { return param.ToUpper(); } }
After
class Program { static void Main() { var list = Enumerable.Range(0, 10); var result = (from item in list let itemAsString = item.ToString(CultureInfo.InvariantCulture) select SomeMethod(ref itemAsString, item)).ToList(); } static string SomeMethod(ref string param, int whatever) { return param.ToUpper(); } }
After conversion there is a compilation error:
Cannot pass the range variable 'itemAsString' as an out or ref parameter
I'm using R# version 6.1.37.86.
The sample application is attached.