Skip to content

Use local function breaks when passing delegate to method taking object #23118

@Pilchie

Description

@Pilchie

Version Used:
VS2017 15.5 P3

Steps to Reproduce:

using System;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Func<string, Task> f = x => { return Task.CompletedTask; };
        Func<string, Task> actual = null;
        AssertSame(f, actual);
    }

    public static void AssertSame(object expected, object actual) { }
}

Expected Behavior:
No suggestion to convert f to a local function, since it breaks the call to AssertSame or a cast to the Func type at the callsite.

Actual Behavior:
Suggestion, which breaks the callsite.

Also the newline in the declaration of f looks really bad.

Metadata

Metadata

Assignees

Labels

Area-IDEBugResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions