提交 8affd7f1 编写于 作者: H Heejae Chang 提交者: GitHub

Merge pull request #17786 from heejaechang/circularref2

don't convert metadata reference to project reference. this workspace…
......@@ -107,6 +107,37 @@ public async Task TestRemoteHostSynchronizeIncrementalUpdate()
}
}
[Fact, Trait(Traits.Feature, Traits.Features.RemoteHost)]
public void TestRemoteWorkspaceCircularReferences()
{
using (var tempRoot = new Microsoft.CodeAnalysis.Test.Utilities.TempRoot())
{
var file = tempRoot.CreateDirectory().CreateFile("p1.dll");
file.CopyContentFrom(typeof(object).Assembly.Location);
var p1 = ProjectId.CreateNewId();
var p2 = ProjectId.CreateNewId();
var solutionInfo = SolutionInfo.Create(
SolutionId.CreateNewId(), VersionStamp.Create(), "",
new[]
{
ProjectInfo.Create(
p1, VersionStamp.Create(), "p1", "p1", LanguageNames.CSharp, outputFilePath: file.Path,
projectReferences: new [] { new ProjectReference(p2) }),
ProjectInfo.Create(
p2, VersionStamp.Create(), "p2", "p2", LanguageNames.CSharp,
metadataReferences: new [] { MetadataReference.CreateFromFile(file.Path) })
});
var remoteWorkspace = new RemoteWorkspace(workspaceKind: "test");
// this shouldn't throw exception
var solution = remoteWorkspace.AddSolution(solutionInfo);
Assert.NotNull(solution);
}
}
private static async Task<Solution> VerifyIncrementalUpdatesAsync(InProcRemoteHostClient client, Solution solution, string csAddition, string vbAddition)
{
Assert.True(PrimaryWorkspace.Workspace is RemoteWorkspace);
......
......@@ -25,6 +25,12 @@ public RemoteWorkspace()
Options = Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0);
}
// constructor for testing
public RemoteWorkspace(string workspaceKind)
: base(RoslynServices.HostServices, workspaceKind: workspaceKind)
{
}
// this workspace doesn't allow modification by calling TryApplyChanges.
// consumer of solution is still free to fork solution as they want, they just can't apply those changes
// back to primary workspace. only solution service can update primary workspace
......@@ -57,7 +63,6 @@ public Solution AddSolution(SolutionInfo solutionInfo)
lock (_gate)
{
this.OnSolutionAdded(solutionInfo);
this.UpdateReferencesAfterAdd();
return this.CurrentSolution;
}
......@@ -81,8 +86,6 @@ public Solution UpdateSolution(Solution solution)
var newSolution = this.SetCurrentSolution(solution);
this.RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind.SolutionChanged, oldSolution, newSolution);
this.UpdateReferencesAfterAdd();
return this.CurrentSolution;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册