Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Simplify ProjectSnapshotManager #11291

Merged

Conversation

DustinCampbell
Copy link
Member

@DustinCampbell DustinCampbell commented Dec 11, 2024

This is the first of several pull requests that will be coming in over the next week. This change refactors the ProjectSnapshotManager to clarify and simplify the logic to prepare solution snapshots in the near future.

It will likely be easier to review commit-by-commit.

Insertion PR for validation: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/597922

- Add factory methods for different ProjectChangeKind values that take the expected inputs.
- Rename SolutionIsClosing to IsSolutionClosing.
- Update ProjectSnapshotManager to use factory methods to create args.
- Update calling code.
While there were excellent comments to describe the behavior of the notification queue, it was still a bit subtle to first peek the notification and only dequeue it when the listeners had been notified. This change introduces a bool field to make it clearer when notifications can be processed. In addition, this change introduces a catch around notification processing and logs any exceptions.
- Introduce TryAddProject method.
- Rename Updater.ProjectAdded to Updater.AddProject
- Introduce TryAddRemove method.
- Rename Updater.ProjectRemoved to Updater.RemoveProject
- Introduce TryUpdateProject methods.
- Push SourceText version logic into ProjectState methods
- Rename ProjectState.WithChangedDocumentText to WithDocumentText
- Rename Updater.DocumentChanged to Updater.UpdateDocumentText
- Rename Updater.DocumentOpened to Updater.OpenDocument
- Rename Updater.DocumentClosed to Updater.CloseDocument
- Use TryUpdateProject
- Rename ProjectState.WithAddedDocuemnt to AddDocument
- Rename Updater.DocumentAdded to Updater.AddDocument
- Use TryUpdateProject
- Rename ProjectState.WithRemovedHostDocument to RemoveDocument
- Rename Updater.DocumentRemoved to Updater.RemoveDcument
- Change RemoveDocument to take file path rather than HostDocument
- Use TryUpdateProject
- Rename Updater.ProjectWorkspaceStateChanged to Updater.UpdateProjectWorkspaceState
- Use TryUpdateProject
- Rename Updater.ProjectConfigurationChanged to Updater.UpdateProjectConfiguration
@DustinCampbell DustinCampbell requested a review from a team as a code owner December 11, 2024 02:15
Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

The biggest nit of all: The tests you updated are all incorrectly named now 😛

Love the cleanup though!

- Quick audit of test names after renaming ProjectState and ProjectSnapshotManager APIs
- Some small clean up and extra overloads to TestMocks.CreateTextLoader.
@DustinCampbell
Copy link
Member Author

The biggest nit of all: The tests you updated are all incorrectly named now

I performed a quick audit of the affected tests and updated any misnaming that I spotted.

@DustinCampbell DustinCampbell merged commit 60d689b into dotnet:main Dec 12, 2024
17 checks passed
@DustinCampbell DustinCampbell deleted the simplify-projectsnapshotmanager branch December 12, 2024 20:56
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Dec 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants