-
Notifications
You must be signed in to change notification settings - Fork 121
Reconcile bare/rich component identities in ComponentsFound #1760
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
Open
AMaini503
wants to merge
1
commit into
main
Choose a base branch
from
user/aamaini/component-identity-merging-level1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+391
−42
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,25 +126,31 @@ private IEnumerable<DetectedComponent> GatherSetOfDetectedComponentsUnmerged(IEn | |
| } | ||
|
|
||
| // Information about each component is relative to all of the graphs it is present in, so we take all graphs containing a given component and apply the graph data. | ||
| foreach (var graphKvp in dependencyGraphsByLocation.Where(x => x.Value.Contains(component.Component.Id))) | ||
| // Also match on BaseId to pick up graphs that registered this component under a bare Id (before reconciliation promoted it to a rich Id). | ||
| foreach (var graphKvp in dependencyGraphsByLocation.Where(x => x.Value.Contains(component.Component.Id) || (component.Component.Id != component.Component.BaseId && x.Value.Contains(component.Component.BaseId)))) | ||
|
Collaborator
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. this line is a bit difficult to follow, can we make a private utility method that returns true when applicable. |
||
| { | ||
| var location = graphKvp.Key; | ||
| var dependencyGraph = graphKvp.Value; | ||
|
|
||
| // Determine the Id stored in this graph — may be the rich Id or the bare BaseId. | ||
| var graphComponentId = dependencyGraph.Contains(component.Component.Id) | ||
| ? component.Component.Id | ||
| : component.Component.BaseId; | ||
|
|
||
| // Calculate roots of the component | ||
| var rootStartTime = DateTime.UtcNow; | ||
| this.AddRootsToDetectedComponent(component, dependencyGraph, componentRecorder); | ||
| this.AddRootsToDetectedComponent(component, graphComponentId, dependencyGraph, componentRecorder); | ||
| var rootEndTime = DateTime.UtcNow; | ||
| totalTimeToAddRoots += rootEndTime - rootStartTime; | ||
|
|
||
| // Calculate Ancestors of the component | ||
| var ancestorStartTime = DateTime.UtcNow; | ||
| this.AddAncestorsToDetectedComponent(component, dependencyGraph, componentRecorder); | ||
| this.AddAncestorsToDetectedComponent(component, graphComponentId, dependencyGraph, componentRecorder); | ||
| var ancestorEndTime = DateTime.UtcNow; | ||
| totalTimeToAddAncestors += ancestorEndTime - ancestorStartTime; | ||
|
|
||
| component.DevelopmentDependency = this.MergeDevDependency(component.DevelopmentDependency, dependencyGraph.IsDevelopmentDependency(component.Component.Id)); | ||
| component.DependencyScope = DependencyScopeComparer.GetMergedDependencyScope(component.DependencyScope, dependencyGraph.GetDependencyScope(component.Component.Id)); | ||
| component.DevelopmentDependency = this.MergeDevDependency(component.DevelopmentDependency, dependencyGraph.IsDevelopmentDependency(graphComponentId)); | ||
| component.DependencyScope = DependencyScopeComparer.GetMergedDependencyScope(component.DependencyScope, dependencyGraph.GetDependencyScope(graphComponentId)); | ||
| component.DetectedBy = detector; | ||
|
|
||
| // Experiments uses this service to build the dependency graph for analysis. In this case, we do not want to update the locations of the component. | ||
|
|
@@ -269,26 +275,26 @@ private DetectedComponent MergeComponents(IEnumerable<DetectedComponent> enumera | |
| return firstComponent; | ||
| } | ||
|
|
||
| private void AddRootsToDetectedComponent(DetectedComponent detectedComponent, IDependencyGraph dependencyGraph, IComponentRecorder componentRecorder) | ||
| private void AddRootsToDetectedComponent(DetectedComponent detectedComponent, string graphComponentId, IDependencyGraph dependencyGraph, IComponentRecorder componentRecorder) | ||
| { | ||
| detectedComponent.DependencyRoots ??= new HashSet<TypedComponent>(new ComponentComparer()); | ||
| if (dependencyGraph == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| detectedComponent.DependencyRoots.UnionWith(dependencyGraph.GetRootsAsTypedComponents(detectedComponent.Component.Id, componentRecorder.GetComponent)); | ||
| detectedComponent.DependencyRoots.UnionWith(dependencyGraph.GetRootsAsTypedComponents(graphComponentId, componentRecorder.GetComponent)); | ||
| } | ||
|
|
||
| private void AddAncestorsToDetectedComponent(DetectedComponent detectedComponent, IDependencyGraph dependencyGraph, IComponentRecorder componentRecorder) | ||
| private void AddAncestorsToDetectedComponent(DetectedComponent detectedComponent, string graphComponentId, IDependencyGraph dependencyGraph, IComponentRecorder componentRecorder) | ||
| { | ||
| detectedComponent.AncestralDependencyRoots ??= new HashSet<TypedComponent>(new ComponentComparer()); | ||
| if (dependencyGraph == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| detectedComponent.AncestralDependencyRoots.UnionWith(dependencyGraph.GetAncestorsAsTypedComponents(detectedComponent.Component.Id, componentRecorder.GetComponent)); | ||
| detectedComponent.AncestralDependencyRoots.UnionWith(dependencyGraph.GetAncestorsAsTypedComponents(graphComponentId, componentRecorder.GetComponent)); | ||
| } | ||
|
|
||
| private HashSet<string> MakeFilePathsRelative(ILogger logger, DirectoryInfo rootDirectory, HashSet<string> filePaths) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.