-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Unify user experience with disparate 'generate constructor' features #76328
Conversation
@@ -1514,7 +1514,8 @@ protected B(int x) | |||
{ | |||
} | |||
} | |||
"""); | |||
""", | |||
index: 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intentional. because code actions were merged, the 0th is now the one in this group that uses the dialog to pick the membes, while the 1nth is the one that creates a delegating constructor.
<data name="Generate_constructor" xml:space="preserve"> | ||
<value>Generate constructor...</value> | ||
<data name="Generate_constructor_from_members" xml:space="preserve"> | ||
<value>Generate constructor from members...</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this string to be clearer about what selecting it will do. Note '...' is our consistent suffix for indicating the user will get a dialog to do the work with. In this case, the new title is indicating that invokign this will give them the dialog taht allows them to pick the members they want the constructor to initialize.
internal abstract partial class AbstractGenerateConstructorFromMembersCodeRefactoringProvider | ||
using static GenerateFromMembersHelpers; | ||
|
||
internal abstract partial class AbstractGenerateConstructorsCodeRefactoringProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed this type to indicate it's for any sort of 'generate constructor' refactoring expereince. not just generating based on members.
// Finally, offer to generate default constructors that delegate to the base type if any are missing. | ||
var defaultConstructorService = document.GetRequiredLanguageService<IGenerateDefaultConstructorsService>(); | ||
var defaultConstructorActions = await defaultConstructorService.GenerateDefaultConstructorsAsync( | ||
document, textSpan, forRefactoring: true, cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was all the other refactoring provider did. just merged it into this shared refactoring provider.
var service = document.GetRequiredLanguageService<IGenerateDefaultConstructorsService>(); | ||
var actions = await service.GenerateDefaultConstructorsAsync( | ||
document, textSpan, forRefactoring: true, cancellationToken).ConfigureAwait(false); | ||
context.RegisterRefactorings(actions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the seperate refactoringg provider. all it did was call into this service and register these refactorings. this is now moved into the single refactoring provider that does all gen-constructor work.
@@ -18,13 +17,9 @@ | |||
|
|||
namespace Microsoft.CodeAnalysis.GenerateFromMembers; | |||
|
|||
internal abstract partial class AbstractGenerateFromMembersCodeRefactoringProvider : CodeRefactoringProvider | |||
internal static class GenerateFromMembersHelpers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed from an abstract base class to a static helper class. this was just full of static helpers and no state. so we didn't need inheritance.
@ToddGrun @JoeRobich ptal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #34206
Merges 'generate base-delegating constructors' and 'generate constructors from members' into one experience so that users don't see 'generate constructor XXX' show up in disparate locations in teh lightbulb
Looks like this: