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

Add refactoring to convert a primary-constructor-parameter to a normal constructor. #70399

Merged
merged 41 commits into from
Oct 19, 2023

Conversation

CyrusNajmabadi
Copy link
Member

We already have an feature to do the reverse. This now lets you switch back easily.

Note: we do want this as primary constructors have limitations (for example, being able to add argument checks). So if a person starts with a primary constructor and wants to easily move off of it to make such changes, we don't want that to be an arduous process.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner October 16, 2023 22:24
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 16, 2023
var parameterLeadingWhitespace = GetLeadingWhitespace(p);
if (parameterLeadingWhitespace.EndsWith(indentation))
var elementLeadingWhitespace = GetLeadingWhitespace(p);
if (elementLeadingWhitespace.EndsWith(indentation))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to be more accurate. this helper was used for more htan just parameters.

var containgTypeAnalyzer = TryGetOrCreateAnalyzer(containingType);
RegisterFieldOrPropertyAnalysisIfNecessary(containgTypeAnalyzer);
var containingTypeAnalyzer = TryGetOrCreateAnalyzer(containingType);
RegisterFieldOrPropertyAnalysisIfNecessary(containingTypeAnalyzer);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mispeeling

CodeActionOptionsProvider optionsProvider,
CancellationToken cancellationToken)
{
var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to doc this method to help make every rewrite step clear. let me know if more clarity is needed.

@CyrusNajmabadi CyrusNajmabadi requested a review from genlu October 17, 2023 20:59
@CyrusNajmabadi
Copy link
Member Author

@genlu ptal.

@CyrusNajmabadi CyrusNajmabadi merged commit b2ea347 into dotnet:main Oct 19, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the convertToRegularConstructor branch October 19, 2023 12:35
@ghost ghost added this to the Next milestone Oct 19, 2023
@jjonescz jjonescz modified the milestones: Next, 17.9 P1 Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants