Version Used:
Microsoft Visual Studio Professional 2017 Preview (2)
Version 15.5.0 Preview 1.0
VisualStudio.15.Preview/15.5.0-pre.1.0+27009.1
Microsoft .NET Framework
Version 4.7.02046
Steps to Reproduce:
- Paste the following code into VS.
using System;
using System.Linq.Expressions;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
new Enclosing<string>.Class<Program>().Caller();
}
}
class Enclosing<T> where T : class
{
delegate T MyDelegate(T t = null);
static void Callee(MyDelegate d) => d(default(T));
public class Class<T> where T : class
{
public void Caller()
{
MyDelegate local = x => x;
Console.WriteLine("");
var doubleDelegate = local + local;
local.Invoke();
Console.WriteLine(nameof(local.ToString));
Expression<Action> expression = () => local(null);
Callee(local);
}
}
}
}
- Convert
MyDelegate local = x => x; to local function as suggested by IDE0039
Expected Behavior:
Either IDE0039 not suggested or code is compilable after such change or conflicts are shown.
Actual Behavior:
- No conflicts:

- Code is completely broken:
using System;
using System.Linq.Expressions;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
new Enclosing<string>.Class<Program>().Caller();
}
}
class Enclosing<T> where T : class
{
delegate T MyDelegate(T t = null);
static void Callee(MyDelegate d) => d(default(T));
public class Class<T> where T : class
{
public void Caller()
{
T local(T x) => x;
Console.WriteLine("");
var doubleDelegate = local + local; // error CS0019
local.Invoke(); // error CS0119
Console.WriteLine(nameof(local.ToString)); // error CS0019
Expression<Action> expression = () => local(null); // error CS8110
Callee(local); // error CS1503
}
}
}
}
Error CS1503 Argument 1: cannot convert from 'method group' to 'Enclosing<T>.MyDelegate'
Error CS0019 Operator '+' cannot be applied to operands of type 'method group' and 'method group'
Error CS0119 'local(T)' is a method, which is not valid in the given context
Error CS0119 'local(T)' is a method, which is not valid in the given context
Error CS8110 An expression tree may not contain a reference to a local function
Version Used:
Steps to Reproduce:
MyDelegate local = x => x;to local function as suggested by IDE0039Expected Behavior:
Either IDE0039 not suggested or code is compilable after such change or conflicts are shown.
Actual Behavior: