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

Lightbulb action to convert an auto property to one that uses field #76899

Closed
drewnoakes opened this issue Jan 24, 2025 · 0 comments · Fixed by #76900
Closed

Lightbulb action to convert an auto property to one that uses field #76899

drewnoakes opened this issue Jan 24, 2025 · 0 comments · Fixed by #76900
Assignees
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@drewnoakes
Copy link
Member

Summary

Given an auto-property:

public string Name { get; set; }

I'd like a lightbulb action to convert it to one that uses field:

public string Name { get => field; set => field = value; }

Background and Motivation

You want to add some custom logic to a property getter or setter, such as to validate state or synthesize the return value.

Today we can use Convert to full property which produces a field on the class:

private string _name;

public string Name { get => _name; set => _name = value; }

We can clean that up, but it's extra work. The field and property can be on different pages of the file and require scrolling, which can break context. It'd be nice to have a way to bypass this intermediate step and stay focused.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Jan 24, 2025
@CyrusNajmabadi CyrusNajmabadi self-assigned this Jan 24, 2025
@CyrusNajmabadi CyrusNajmabadi added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 24, 2025
@github-project-automation github-project-automation bot moved this to InQueue in Small Fixes Jan 24, 2025
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Jan 24, 2025
@github-project-automation github-project-automation bot moved this from InQueue to Completed in Small Fixes Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

2 participants