Skip to content

Missing quick refactor action to convert event add/remove into expression body #59255

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


If you have code like this:

public event RoutedEventHandler SomeEvent
{
  add 
  {
    this. AddHandler(SomeEventEvent, value);
  }
  remove
  {
    this. RemoveHandler(SomeEventEvent, value);
  }
}

There is no quick action to refactor to this:

public event RoutedEventHandler SomeEvent
{
  add => this. AddHandler(SomeEventEvent, value);
  remove => this. RemoveHandler(SomeEventEvent, value);
}

This is missing refactoring functionality that ReSharper has.


Original Comments

Feedback Bot on 1/28/2022, 10:58 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 2/2/2022, 08:44 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

Feedback Bot solved on 2/2/2022, 08:46 PM, 0 votes:

Thanks for taking the time to report this issue! It seems to us that it’s describing the same thing as another one. We’ve closed this one as a duplicate and transferred all votes from this ticket to the other one. Please follow along on the linked ticket to communicate with the team, see updates on status, and help provide any needed diagnostic info. For more information, see our issue reporting guidelines.

Happy coding!

Adam Meltzer [MSFT] on 2/3/2022, 10:27 AM:

This is not the same thing. This isn’t a request to do a “fix all”, this is literally a completely absent refactor action.

Sam Harwell [MSFT] solved on 2/2/2022, 09:47 AM, 1 votes:

Thanks for taking the time to report this issue! It seems to us that it’s describing the same thing as another one. We’ve closed this one as a duplicate and transferred all votes from this ticket to the other one. Please follow along on the linked ticket to communicate with the team, see updates on status, and help provide any needed diagnostic info. For more information, see our issue reporting guidelines.

Happy coding!

Hi @Adam Meltzer [MSFT],

Currently, the .editorconfig for the project specifies that block-bodied members are preferred for accessors. We still allow manual refactoring in the opposite (non-preferred) direction, but CodeRefactoringProvider does not currently allow for a Fix All operation. If expression-bodied accessors are preferred for your project, I would recommend updating the .editorconfig to indicate this preference, at which point a Fix All operation will be available.

Thank you,
Sam Harwell

Metadata

Metadata

Assignees

Labels

Area-IDEBugDeveloper CommunityThe issue was originally reported on https://developercommunity.visualstudio.comIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions