Reporter | James Manning (James.Manning) |
---|---|
Created | Dec 16, 2011 8:01:12 PM |
Updated | Mar 16, 2012 12:53:38 AM |
Priority | Critical |
Type | Bug |
Fix versions | 7.0 |
State | Open |
Assignee | Sergey Shkredov (serjic.shkredov) |
Subsystem | Refactoring |
Affected versions | 6.1 |
Fixed in build | No Fixed in build |
JetBrains ReSharper 6.1 EAP C# Edition Pre-Release
Build 6.1.29.21 on 2011-12-11T02:59:02
Plugins: none
Visual Studio 10.0.40219.1.
This might just be a limitation caused by the generic type inference, but off-hand it seems like R# has sufficient information to determine it (although I'm certainly not looking at the more general case).
In the below code (simplified repro of the situation I actually hit, of course :) when doing extract method on SquareNumber (does not yet exist), while the VS/C# compiler isn't able to infer the generic type params e 'exto Select (causing the compiler error tooltip on the 'generator' return and the 'Select' method call), it seems like there's enough info there for R# to determine that the return value for SquareNumber is likely to be 'int'.
Since the 'extract method' just puts in a default return value (in the current behavior, of 'object'), then having it choose 'int' as a better return value doesn't have to be right 100% of the time (the user can still change the return value as part of the 'live template') but it would be a better user experience to default to 'int' instead. :)
Build 6.1.29.21 on 2011-12-11T02:59:02
Plugins: none
Visual Studio 10.0.40219.1.
This might just be a limitation caused by the generic type inference, but off-hand it seems like R# has sufficient information to determine it (although I'm certainly not looking at the more general case).
In the below code (simplified repro of the situation I actually hit, of course :) when doing extract method on SquareNumber (does not yet exist), while the VS/C# compiler isn't able to infer the generic type params e 'exto Select (causing the compiler error tooltip on the 'generator' return and the 'Select' method call), it seems like there's enough info there for R# to determine that the return value for SquareNumber is likely to be 'int'.
Since the 'extract method' just puts in a default return value (in the current behavior, of 'object'), then having it choose 'int' as a better return value doesn't have to be right 100% of the time (the user can still change the return value as part of the 'live template') but it would be a better user experience to default to 'int' instead. :)
using System; using System.Linq; class Program { static void Main(string[] args) { var results = Foo(); Console.WriteLine(results); } static int[] Foo() { var generator = Enumerable.Range(1, 10) .Select(i => SquareNumber(i)) .ToArray(); return generator; } }