Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Replace method with property" replaces non-invoked method with property #35002

Closed
vatsalyaagrawal opened this Issue Apr 16, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@vatsalyaagrawal
Copy link

vatsalyaagrawal commented Apr 16, 2019

16.0.1

Original code:

delegate int Mdelegate();

class C
{
    int GetP() => 0;

    void M()
    {
        Mdelegate del = new Mdelegate(GetP);
    }
}

Use Replace 'GetP' with property refactoring.

Refactored Code:

delegate int Mdelegate();

class C
{
    int P => 0;

    void M()
    {
        Mdelegate del = new Mdelegate(P);
    }
}

Note that refactored code will not compile as a property can not be used in place of a method in the delegate.

@CyrusNajmabadi

This comment has been minimized.

Copy link
Contributor

CyrusNajmabadi commented Apr 16, 2019

Yes. This is by design. You asked us to replace the method with a property. We did the best we could here, you'll have to fixup any remaining problems.

Note: i even wrote the feature to detect this and give a message in the preview to this effect:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.