Skip to content

Commit

Permalink
Merge pull request dotnet#4405 from jmarolf/remove-another-use-of-ban…
Browse files Browse the repository at this point in the history
…ned-api

remove use of IProjectLockService
jmarolf authored Dec 18, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 1f4f847 + 07dafab commit 53b4306
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ internal class DependenciesProjectTreeProvider
private readonly ICrossTargetSubscriptionsHost _dependenciesHost;
private readonly IDependenciesSnapshotProvider _dependenciesSnapshotProvider;
private readonly IProjectAsynchronousTasksService _tasksService;
private readonly IProjectAccessor _projectAccessor;
private readonly IDependencyTreeTelemetryService _treeTelemetryService;

/// <summary>Latest updated snapshot of all rules schema catalogs.</summary>
@@ -58,6 +59,7 @@ internal class DependenciesProjectTreeProvider
[ImportingConstructor]
public DependenciesProjectTreeProvider(
IProjectThreadingService threadingService,
IProjectAccessor projectAccessor,
UnconfiguredProject unconfiguredProject,
IDependenciesSnapshotProvider dependenciesSnapshotProvider,
[Import(DependencySubscriptionsHost.DependencySubscriptionsHostContract)] ICrossTargetSubscriptionsHost dependenciesHost,
@@ -76,6 +78,7 @@ public DependenciesProjectTreeProvider(
_dependenciesSnapshotProvider = dependenciesSnapshotProvider;
_dependenciesHost = dependenciesHost;
_tasksService = tasksService;
_projectAccessor = projectAccessor;
_treeTelemetryService = treeTelemetryService;

// Hook this so we can unregister the snapshot change event when the project unloads
@@ -199,11 +202,8 @@ public override async Task RemoveAsync(IImmutableSet<IProjectTree> nodes,
// Get the list of normal reference Item Nodes (this excludes any shared import nodes).
IEnumerable<IProjectTree> referenceItemNodes = nodes.Except(sharedImportNodes);

#pragma warning disable RS0030 // symbol IProjectLockService is banned
await ProjectLockService.WriteLockAsync(async access =>
await _projectAccessor.OpenProjectForWriteAsync(ActiveConfiguredProject, project =>
{
Project project = await access.GetProjectAsync(ActiveConfiguredProject);

// Handle the removal of normal reference Item Nodes (this excludes any shared import nodes).
foreach (IProjectTree node in referenceItemNodes)
{
@@ -227,7 +227,6 @@ await ProjectLockService.WriteLockAsync(async access =>
Report.IfNot(unresolvedReferenceItem != null, "Cannot find reference to remove.");
if (unresolvedReferenceItem != null)
{
await access.CheckoutAsync(unresolvedReferenceItem.Xml.ContainingProject.FullPath);
project.RemoveItem(unresolvedReferenceItem);
}
}
@@ -240,7 +239,7 @@ await ProjectLockService.WriteLockAsync(async access =>
}

// Handle the removal of shared import nodes.
ProjectRootElement projectXml = await access.GetProjectXmlAsync(UnconfiguredProject.FullPath);
ProjectRootElement projectXml = project.Xml;
foreach (IProjectTree sharedImportNode in sharedImportNodes)
{
string sharedFilePath = UnconfiguredProject.MakeRelative(sharedImportNode.FilePath);
@@ -268,13 +267,11 @@ await ProjectLockService.WriteLockAsync(async access =>
"Cannot find shared project reference to remove.");
if (importingElementToRemove != null)
{
await access.CheckoutAsync(importingElementToRemove.ContainingProject.FullPath);
importingElementToRemove.Parent.RemoveChild(importingElementToRemove);
}
}
}
});
#pragma warning restore RS0030 // symbol IProjectLockService is banned
}

/// <summary>

0 comments on commit 53b4306

Please sign in to comment.