Closed TessenR closed 6 years ago
Cute. Let me know if you want any info on this @chborl :)
Thanks @CyrusNajmabadi! I'll take a look at this in the next couple of days.
I also have this refactoring suggested in a case where it breaks code.
Here is a minimal repro
static class FunctionExtensions
{
public static Func<TResult> Apply<T, TResult>(this Func<T, TResult> f, T x) => () => f(x);
}
class Program
{
static void Main(string[] args)
{
Func<int, int> addOne = x => x + 1; // IDE0039 suggested
var getSix = addOne.Apply(5);
}
}
IDE suggests replacing f
with a local function which prevents it from being the receiver of the extension method Apply
.
Let me know if I should open a separate issue.
Version Details: Microsoft Visual Studio Professional 2017 Preview Version 15.5.0 Preview 3.0 VisualStudio.15.Preview/15.5.0-pre.3.0+27102.0 Microsoft .NET Framework Version 4.7.02556
Visual C# 2017 00369-60000-00001-AA141 Microsoft Visual C# 2017
@aluanhaddad I think it's fine to keep that case rolled into this one.
@CyrusNajmabadi thanks!
Version Used:
Steps to Reproduce:
namespace ConsoleApp1 { class Program { static void Main(string[] args) { new Enclosing.Class().Caller();
}
}
class Enclosing where T : class
{
delegate T MyDelegate(T t = null);
static void Callee(MyDelegate d) => d(default(T));
} }