Reporter | Joe White (joewhite) |
---|---|
Created | Jan 13, 2012 10:26:58 PM |
Updated | Jan 13, 2012 10:26:58 PM |
Priority | Normal |
Type | Feature |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Unassigned |
Subsystem | No subsystem |
Affected versions | 6.1 |
Fixed in build | No Fixed in build |
Sometimes, I'll refactor to the point where my code is creating a lambda (or anonymous delegate), immediately calling that lambda once or twice, and then not using it again. It would be great if ReSharper had some ability to inline this.
(In some cases, it already can. If the lambda doesn't use any closure variables, then I can first use the quick-fix to change it to a named method, and then inline that named method. However, if the lambda does use closure variables, then the "To named method" quick-fix is not available.)
Example:
(In some cases, it already can. If the lambda doesn't use any closure variables, then I can first use the quick-fix to change it to a named method, and then inline that named method. However, if the lambda does use closure variables, then the "To named method" quick-fix is not available.)
Example:
// Input: var clauses = new List<string>(); Action<string> appendCondition = condition => clauses.Add("(" + condition + ")"); appendCondition("Balance < 0"); // Output after inlining the lambda: var clauses = new List<string>(); clauses.Add("(" + "Balance < 0" + ")");