-
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
Fine tuning of what types of project update affect what state #11213
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,26 +274,36 @@ public ProjectState WithChangedHostDocument(HostDocument hostDocument, TextLoade | |
|
||
public ProjectState WithHostProjectAndWorkspaceState(HostProject hostProject, ProjectWorkspaceState projectWorkspaceState) | ||
{ | ||
if (HostProject.Configuration.Equals(hostProject.Configuration) && | ||
HostProject.RootNamespace == hostProject.RootNamespace && | ||
ProjectWorkspaceState.Equals(projectWorkspaceState)) | ||
var configUnchanged = (HostProject.Configuration.Equals(hostProject.Configuration) && | ||
HostProject.RootNamespace == hostProject.RootNamespace); | ||
|
||
if (configUnchanged && ProjectWorkspaceState.Equals(projectWorkspaceState)) | ||
{ | ||
return this; | ||
} | ||
|
||
var documents = Documents.ToImmutableDictionary(kvp => kvp.Key, kvp => kvp.Value.WithProjectChange(), FilePathNormalizingComparer.Instance); | ||
var documents = Documents.ToImmutableDictionary(kvp => kvp.Key, kvp => kvp.Value.WithProjectChange(cacheComputedState: configUnchanged), FilePathNormalizingComparer.Instance); | ||
|
||
// If the host project has changed then we need to recompute the imports map | ||
var importsToRelatedDocuments = s_emptyImportsToRelatedDocuments; | ||
var importsToRelatedDocuments = configUnchanged | ||
? ImportsToRelatedDocuments | ||
: ComputeImportsToRelatedDocuments(documents); | ||
|
||
var state = new ProjectState(this, numberOfDocumentsMayHaveChanged: !configUnchanged, hostProject, projectWorkspaceState, documents, importsToRelatedDocuments); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit hidden, so I'll call it out here. Where I said in the PR description that updating the In my original PR I equated any project change to a possible document change, but tag helpers changing is definitely not that. |
||
return state; | ||
|
||
foreach (var document in documents) | ||
ImmutableDictionary<string, ImmutableArray<string>> ComputeImportsToRelatedDocuments(ImmutableDictionary<string, DocumentState> documents) | ||
{ | ||
var importTargetPaths = GetImportDocumentTargetPaths(document.Value.HostDocument); | ||
importsToRelatedDocuments = AddToImportsToRelatedDocuments(importsToRelatedDocuments, document.Value.HostDocument.FilePath, importTargetPaths); | ||
} | ||
var importsToRelatedDocuments = s_emptyImportsToRelatedDocuments; | ||
|
||
var state = new ProjectState(this, numberOfDocumentsMayHaveChanged: true, hostProject, projectWorkspaceState, documents, importsToRelatedDocuments); | ||
return state; | ||
foreach (var document in documents) | ||
{ | ||
var importTargetPaths = GetImportDocumentTargetPaths(document.Value.HostDocument); | ||
importsToRelatedDocuments = AddToImportsToRelatedDocuments(importsToRelatedDocuments, document.Value.HostDocument.FilePath, importTargetPaths); | ||
} | ||
|
||
return importsToRelatedDocuments; | ||
} | ||
} | ||
|
||
internal static ImmutableDictionary<string, ImmutableArray<string>> AddToImportsToRelatedDocuments( | ||
|
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.
I'm still not sure when or why this should be true or false. I see in the PR but not really the impact of it
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.
I'll admit this isn't great, and I think the reasoning around what the computed state actually achieves, and whether its worth caching, is not fully understood by anyone. Or perhaps better said, I don't think I, or anyone else, could write a convincing comment explaining why this value should be true or false. I've made things match previous behaviour, and that seems to have had no bad outcomes, and I look forward to Dustin removing the computed state tracker in the future.