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

Provide Constructor Refactoring Using Tuple Syntax #49037

Open
vsfeedback opened this issue Oct 29, 2020 · 0 comments
Open

Provide Constructor Refactoring Using Tuple Syntax #49037

vsfeedback opened this issue Oct 29, 2020 · 0 comments
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@vsfeedback
Copy link

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


  1. Create a class with multiple properties, like this:
public class LotsOfData
{
	public Guid GuidValue { get; }
	public int IntData { get; }
	public string StringValue { get; }
}
  1. Select the Generate constructor... refactoring, and keep the default selections.
  2. The resulting constructor looks like this:
public class LotsOfData
{
	public LotsOfData(Guid guidValue, int intData, string stringValue)
	{
		this. GuidValue = guidValue;
		this. IntData = intData;
		this. StringValue = stringValue;
	}

public Guid GuidValue { get; }
	public int IntData { get; }
	public string StringValue { get; }
}

What I'd love to have is an option to generate the constructor using tuples for initialization:

public class LotsOfData
{
	public LotsOfData(Guid guidValue, int intData, string stringValue)
	{
		(this. GuidValue, this. IntData, this. StringValue) =
			(guidValue, intData, stringValue); 
	}

public Guid GuidValue { get; }
	public int IntData { get; }
	public string StringValue { get; }
}

From what I understand about this approach, it has the same perf characteristics. It's also a little more succinct, which I like, and it allows me to use an expression-bodied constructor (which removes the curly braces for the constructor).


Original Comments

Feedback Bot on 5/20/2020, 02:43 AM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 29, 2020
@jinujoseph jinujoseph added Concept-Continuous Improvement 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 Nov 4, 2020
@jinujoseph jinujoseph added this to the Backlog milestone Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

No branches or pull requests

3 participants