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

Disable extract class/interface to a new file when unsupported by the workspace. #76717

Merged
merged 4 commits into from
Jan 14, 2025

Conversation

JoeRobich
Copy link
Member

Doing this as part of the work to bring these extract refactorings to the LSP.

This PR does two things:

  1. It updates the ExtractInterfaceOptionsService to pull the services it needs from the document being worked against. This will have it work in the same manner as ExtractClassOptionsService. This also removes the need for Roslyn LSP or O# to implement an INotificationService since it is only needed in the VisualStudioExtractInferfaceOptionsService.
  2. A change was previously made to have extract class early return if the workspace did not support AddFile operations. The same change was not made for extract interface and both support extracting to a new file. This PR changes it so that extract class is supported again, however the option to extract to new file will be disabled when unsupported by the workspace.

@JoeRobich JoeRobich requested a review from a team as a code owner January 11, 2025 07:22
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 11, 2025
@@ -33,14 +31,12 @@ internal sealed class TestExtractInterfaceOptionsService() : IExtractInterfaceOp
public bool SameFile { get; set; }

public ExtractInterfaceOptionsResult GetExtractInterfaceOptions(
ISyntaxFactsService syntaxFactsService,
INotificationService notificationService,
Document document,
Copy link
Member Author

Choose a reason for hiding this comment

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

The services and language can be pulled from the document.

var solution = context.Document.Project.Solution;
if (!solution.CanApplyChange(ApplyChangesKind.AddDocument))
Copy link
Member Author

Choose a reason for hiding this comment

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

This will now be handled by disabling the new file option on the extract dialog.

@@ -20,7 +20,8 @@ internal class NewTypeDestinationSelectionViewModel : AbstractNotifyPropertyChan
string.Empty,
string.Empty,
[],
null
null,
false
Copy link
Member

Choose a reason for hiding this comment

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

named parameters.

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

love the simplification.

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 UX Review Not Required UX Review Not Required VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants