Skip to content

"Simplify member access" not offered after cast expression to function pointer type #81113

@jhinder

Description

@jhinder

Version Used: VS 18.0.0 Insiders

Steps to Reproduce:
Open the lightbulb menu at the marked locations.

unsafe class C
{
    static void M1()
    {
        delegate*<void> d = &C.M1;
        d();
    }

    static void M2()
    {
        var d = (delegate*<void>)(&C.M2);
        d();
    }
}

Expected Behavior:
"Simplify member access" is offered at both locations, simplifying the expression to M1 and M2, respectively.

Actual Behavior:
For the reference to C.M1, the refactoring is offered and the expression can be simplified (the "C" identifier is also greyed out to indicate a possible simplification).
For the reference to C.M2, the refactoring is not offered (even though it can be simplified) and the "C" identifier is not greyed out.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions