提交 e19286c5 编写于 作者: S Sam Harwell

Use consistent calling convention for updates

上级 63612753
......@@ -23,10 +23,7 @@ internal ProjectDependencyGraph WithAdditionalProjectReferences(ProjectId projec
var newReferencesMap = ComputeNewReferencesMapForAdditionalProjectReferences(_referencesMap, projectId, referencedProjectIds);
var newReverseReferencesMap =
_lazyReverseReferencesMap != null
? ComputeNewReverseReferencesMapForAdditionalProjectReferences(_lazyReverseReferencesMap, projectId, referencedProjectIds)
: null;
var newReverseReferencesMap = ComputeNewReverseReferencesMapForAdditionalProjectReferences(_lazyReverseReferencesMap, projectId, referencedProjectIds);
var newTransitiveReferencesMap = ComputeNewTransitiveReferencesMapForAdditionalProjectReferences(_transitiveReferencesMap, projectId, referencedProjectIds);
......@@ -64,13 +61,15 @@ internal ProjectDependencyGraph WithAdditionalProjectReferences(ProjectId projec
/// <summary>
/// Computes a new <see cref="_lazyReverseReferencesMap"/> for the addition of additional project references.
/// Must be called on a non-null map.
/// </summary>
private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReverseReferencesMapForAdditionalProjectReferences(
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReverseReferencesMap,
private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? ComputeNewReverseReferencesMapForAdditionalProjectReferences(
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
ProjectId projectId,
IReadOnlyList<ProjectId> referencedProjectIds)
{
if (existingReverseReferencesMap is null)
return null;
var builder = existingReverseReferencesMap.ToBuilder();
foreach (var referencedProject in referencedProjectIds)
......
......@@ -23,12 +23,10 @@ internal ProjectDependencyGraph WithProjectRemoved(ProjectId projectId)
// The direct reverse references map is updated by removing the key for the project getting removed, and
// also updating any direct references to the removed project.
var reverseReferencesMap = _lazyReverseReferencesMap is object
? ComputeNewReverseReferencesMapForRemovedProject(
existingForwardReferencesMap: _referencesMap,
existingReverseReferencesMap: _lazyReverseReferencesMap,
projectId)
: null;
var reverseReferencesMap = ComputeNewReverseReferencesMapForRemovedProject(
existingForwardReferencesMap: _referencesMap,
existingReverseReferencesMap: _lazyReverseReferencesMap,
projectId);
var transitiveReferencesMap = ComputeNewTransitiveReferencesMapForRemovedProject(_transitiveReferencesMap, projectId);
var reverseTransitiveReferencesMap = ComputeNewReverseTransitiveReferencesMapForRemovedProject(_reverseTransitiveReferencesMap, projectId);
return new ProjectDependencyGraph(
......@@ -84,11 +82,17 @@ internal ProjectDependencyGraph WithProjectRemoved(ProjectId projectId)
/// <summary>
/// Computes a new <see cref="_lazyReverseReferencesMap"/> for the removal of a project.
/// </summary>
private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReverseReferencesMapForRemovedProject(
private static ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? ComputeNewReverseReferencesMapForRemovedProject(
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingForwardReferencesMap,
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReverseReferencesMap,
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
ProjectId projectId)
{
if (existingReverseReferencesMap is null)
{
// The map was never calculated for the previous graph, so there is nothing to update.
return null;
}
var builder = existingReverseReferencesMap.ToBuilder();
// Iterate over each project referenced by 'projectId', which is now being removed. Update the reverse
......
......@@ -20,9 +20,7 @@ internal ProjectDependencyGraph WithProjectReferenceRemoved(ProjectId projectId,
// Incrementally update the graph
var referencesMap = _referencesMap.SetItem(projectId, _referencesMap[projectId].Remove(referencedProjectId));
var reverseReferencesMap = _lazyReverseReferencesMap is object
? ComputeNewReverseReferencesMapForRemovedProjectReference(_lazyReverseReferencesMap, projectId, referencedProjectId)
: null;
var reverseReferencesMap = ComputeNewReverseReferencesMapForRemovedProjectReference(_lazyReverseReferencesMap, projectId, referencedProjectId);
var transitiveReferencesMap = ComputeNewTransitiveReferencesMapForRemovedProjectReference(_transitiveReferencesMap, projectId, referencedProjectId);
var reverseTransitiveReferencesMap = ComputeNewReverseTransitiveReferencesMapForRemovedProjectReference(_reverseTransitiveReferencesMap, projectId, referencedProjectId);
......@@ -36,11 +34,14 @@ internal ProjectDependencyGraph WithProjectReferenceRemoved(ProjectId projectId,
dependencySets: default);
}
private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> ComputeNewReverseReferencesMapForRemovedProjectReference(
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>> existingReverseReferencesMap,
private ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? ComputeNewReverseReferencesMapForRemovedProjectReference(
ImmutableDictionary<ProjectId, ImmutableHashSet<ProjectId>>? existingReverseReferencesMap,
ProjectId projectId,
ProjectId referencedProjectId)
{
if (existingReverseReferencesMap is null)
return null;
if (existingReverseReferencesMap.TryGetValue(referencedProjectId, out var referencingProjects))
{
return existingReverseReferencesMap.SetItem(referencedProjectId, referencingProjects.Remove(projectId));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册