Skip to content

"Generate method" does not add static modifier when generating method for function pointer #80984

@jhinder

Description

@jhinder

Version Used: VS 18.0.0 Insiders [11123.170]

Steps to Reproduce:
Invoke the lightbulb menu and select "Generate method 'M2'".

unsafe class C
{
    private void M()
    {
        delegate* managed<void> x = &M2;
    }
}

Expected Behavior:
The method is generated with the static modifier.

Actual Behavior:
The method is generated without the static modifier, leading to an error:

unsafe class C
{
    private void M()
    {
        delegate* managed<void> x = &M2; // CS8759: Cannot create a function pointer for 'C.M2()' because it is not a static method
    }

    private void M2()
    {
        throw new NotImplementedException();
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions