-
Notifications
You must be signed in to change notification settings - Fork 199
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
Further refactoring of Razor tooling project system #11320
Further refactoring of Razor tooling project system #11320
Conversation
The Razor project/document state model only need two compiler options: ForceRuntimeCodeGeneration and UseRoslynTokenizer. So, using LanguageServerFeatureOptions directly within ProjectState is a bit overkill. This change introduces a new enum, RazorCompilerOptions, to track the two options that the project model needs to control Razor compilation.
This change cleans up the TestProjectEngineFactoryProvider to be a bit more usable.
There were a number of test hooks in DocumentState and ProjectState, such as settable properties and virtual methods. This change removes those test hooks by cleaning up and refactoring ProjectStateTest.
This change attempts to be a bit more efficient what updating the ImportsToRelatedDocuments map. In addition, related documents are now stored in ImmutableHashSets.
This change brings Roslyn's AsyncLazy<T> implementation to Razor, but removes the synchronous computation path, since Razor doesn't need it.
This change removes the DocumentState.ComputedTracker, and DocumentState no longer weakly caches it's generated RazorCodeDocument. In addition, IDocumentSnapshot.GetGeneratedOutputAsync(...) has been modified to remove the forceDesignTimeGeneratedOutput parameter and the remove project/document snapshot implementations now use Razor's Roslyn-based AsyncLazy.
This change adds ILegacyDocumentSnapshot and ILegacyProjectSnapshot to be used exclusively by the legacy editor. These provide synchronous methods that should *only* be used by the legacy editor.
This property isn't actually used outside of ProjectState.
This change fully removes the IProjectSnapshotManager interface. Components in the language server and VS client layers can import a ProjectSnapshotManager. ProjectSnapshotManager provides direct access to DocumentSnapshot and ProjectSnapshot, which implement IDocumentSnapshot and IProjectSnapshot.
Retrieving a RazorProjectEngine for a project snapshot is an implementation detail and doesn't need to be exposed on IProjectSnapshot.
ProjectWorkspaceState is an implementation detail and does not need to be exposed on IProjectSnapshot.
IDocumentSnapshot and IProjectSnapshot and now more fundamental and below in a lower layer of Razor tooling.
The RazorConfiguration of a project snapshot is an implementation detail and doesn't need to be exposed.
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 is so awesome. I did have a few questions though, that are probably just me missing something or misunderstanding something.
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/CompilationHelpers.cs
Outdated
Show resolved
Hide resolved
...r/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Sources/GeneratedOutputSource.cs
Show resolved
Hide resolved
...r/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/Sources/GeneratedOutputSource.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IDesignTimeCodeGenerator.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LegacyEditor.Razor/EphemeralProjectSnapshot.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectDifference.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/ProjectSystem/RemoteProjectSnapshot.cs
Outdated
Show resolved
Hide resolved
In my professional opinion, we can consider the integration tests to have passed. The one failing test, |
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.
Looking good! Most of this may seem scattered. I reviewed commit by commit since the UI for over 200 files wasn't working too well. Thanks for the detailed commit messages
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
Outdated
Show resolved
Hide resolved
ValueTask<RazorCodeDocument> GetGeneratedOutputAsync( | ||
bool forceDesignTimeGeneratedOutput, | ||
CancellationToken cancellationToken); | ||
ValueTask<RazorCodeDocument> GetGeneratedOutputAsync(CancellationToken cancellationToken); |
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.
💡 should we take the time to change this to GetGeneratedDocumentAsync
? 👀
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.
Not yet. I have a whole series of renames coming soon. IDocumentSnapshot
will become IRazorDocument
, IProjectSnapshot
will become IRazorProject
.
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshot.cs
Show resolved
Hide resolved
...azor.LanguageServer.Test/CodeActions/Razor/ExtractToComponentCodeActionResolverTest.NetFx.cs
Show resolved
Hide resolved
To account for recent formatting changes in main, `IDesignTimeCodeGenerator` does not compile if `FORMAT_FUSE` is defined.
Changes in this PR caused the number of projects needing to compile with FORMAT_FUSE from two to four. So, this change pushes FORMAT_FUSE into Directory.Build.props to avoid needing to update four project files.
There's a lot of code changes here
IProjectSnapshotManger
interface completelyIDocumentSnapshot
andIProjectSnapshot
down to MS.ANC.Razor.ProjectEngineHostILegacyDocumentSnapshot
andILegacyProjectSnapshot
to serve the needs of the legacy editor.IDocumentSnapshot
andIProjectSnapshot
and hide implementation details, such asConfiguration
,ProjectWorkspaceState
andGetProjectEngine()
.ComputedStateTracker
and stop weakly cachingRazorCodeDocument
onDocumentState
.AsyncLazy
from Roslyn. (A key difference between this and the VSAsyncLazy
is that it doesn't have a JTF dependency.)ProjectState
.ProjectState
andDocumentState
API.VS Insertion PR: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/599715