提交 efa13d18 编写于 作者: J Jason Malinowski

Remove ProjectState/SolutionState.AddProjectReference

We already have an API for adding multiple project references; let's
just use that at the public entrypoints than trying to maintain
near-duplicate code.
上级 ad33e5c1
......@@ -471,14 +471,6 @@ public static bool IsSameLanguage(ProjectState project1, ProjectState project2)
return project1.LanguageServices == project2.LanguageServices;
}
public ProjectState AddProjectReference(ProjectReference projectReference)
{
Contract.Requires(!this.ProjectReferences.Contains(projectReference));
return this.With(
projectInfo: this.ProjectInfo.WithProjectReferences(this.ProjectReferences.ToImmutableArray().Add(projectReference)).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState RemoveProjectReference(ProjectReference projectReference)
{
Contract.Requires(this.ProjectReferences.Contains(projectReference));
......
......@@ -401,7 +401,7 @@ internal Solution WithHasAllInformation(ProjectId projectId, bool hasAllInformat
/// </summary>
public Solution AddProjectReference(ProjectId projectId, ProjectReference projectReference)
{
var newState = _state.AddProjectReference(projectId, projectReference);
var newState = _state.AddProjectReferences(projectId, SpecializedCollections.SingletonEnumerable(projectReference));
if (newState == _state)
{
return this;
......
......@@ -769,35 +769,6 @@ private static async Task<Compilation> ReplaceSyntaxTreesWithTreesFromNewProject
return compilation.RemoveAllSyntaxTrees().AddSyntaxTrees(syntaxTrees);
}
/// <summary>
/// Create a new solution instance with the project specified updated to include
/// the specified project reference.
/// </summary>
public SolutionState AddProjectReference(ProjectId projectId, ProjectReference projectReference)
{
if (projectId == null)
{
throw new ArgumentNullException(nameof(projectId));
}
if (projectReference == null)
{
throw new ArgumentNullException(nameof(projectReference));
}
CheckContainsProject(projectId);
CheckContainsProject(projectReference.ProjectId);
CheckNotContainsProjectReference(projectId, projectReference);
CheckNotContainsTransitiveReference(projectReference.ProjectId, projectId);
CheckNotSecondSubmissionReference(projectId, projectReference.ProjectId);
var oldProject = this.GetProjectState(projectId);
var newProject = oldProject.AddProjectReference(projectReference);
return this.ForkProject(newProject, withProjectReferenceChange: true);
}
/// <summary>
/// Create a new solution instance with the project specified updated to include
/// the specified project references.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册