Skip to content

Commit

Permalink
Merge pull request #53599 from jasonmalinowski/add-api-for-adding-ass…
Browse files Browse the repository at this point in the history
…embly-name

Add a parameter to pass through the initial assembly name
  • Loading branch information
jasonmalinowski authored May 27, 2021
2 parents 060bd54 + c2388e7 commit ce652d5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static async Task<CPSProject> CreateCSharpCPSProjectAsync(TestEnvironment
projectGuid,
hierarchy,
binOutputPath,
assemblyName: null,
CancellationToken.None);

cpsProject.SetOptions(ImmutableArray.Create(commandLineArguments));
Expand All @@ -105,6 +106,7 @@ public static async Task<CPSProject> CreateNonCompilableProjectAsync(TestEnviron
Guid.NewGuid(),
hierarchy,
binOutputPath: null,
assemblyName: null,
CancellationToken.None);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -17,7 +15,11 @@ internal interface IWorkspaceProjectContextFactory
{
/// <inheritdoc cref="CreateProjectContextAsync"/>
[Obsolete("Use CreateProjectContextAsync instead")]
IWorkspaceProjectContext CreateProjectContext(string languageName, string projectUniqueName, string projectFilePath, Guid projectGuid, object hierarchy, string binOutputPath);
IWorkspaceProjectContext CreateProjectContext(string languageName, string projectUniqueName, string projectFilePath, Guid projectGuid, object? hierarchy, string? binOutputPath);

/// <inheritdoc cref="CreateProjectContextAsync"/>
[Obsolete("Use CreateProjectContextAsync instead")]
IWorkspaceProjectContext CreateProjectContext(string languageName, string projectUniqueName, string projectFilePath, Guid projectGuid, object? hierarchy, string? binOutputPath, string? assemblyName);

/// <summary>
/// Creates and initializes a new Workspace project and returns a <see
Expand All @@ -29,8 +31,16 @@ internal interface IWorkspaceProjectContextFactory
/// <param name="projectUniqueName">Unique name for the project.</param>
/// <param name="projectFilePath">Full path to the project file for the project.</param>
/// <param name="projectGuid">Project guid.</param>
/// <param name="hierarchy">Obsolete. The argument is ignored.</param>
/// <param name="hierarchy">The IVsHierarchy for the project; this is used to track linked files across multiple projects when determining contexts.</param>
/// <param name="binOutputPath">Initial project binary output path.</param>
Task<IWorkspaceProjectContext> CreateProjectContextAsync(string languageName, string projectUniqueName, string projectFilePath, Guid projectGuid, object hierarchy, string binOutputPath, CancellationToken cancellationToken);
Task<IWorkspaceProjectContext> CreateProjectContextAsync(
string languageName,
string projectUniqueName,
string projectFilePath,
Guid projectGuid,
object? hierarchy,
string? binOutputPath,
string? assemblyName,
CancellationToken cancellationToken);
}
}
20 changes: 13 additions & 7 deletions src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.ComponentModel.Composition;
using System.Threading;
Expand Down Expand Up @@ -43,25 +41,33 @@ public CPSProjectFactory(
_serviceProvider = (Shell.IAsyncServiceProvider)serviceProvider;
}

IWorkspaceProjectContext IWorkspaceProjectContextFactory.CreateProjectContext(string languageName, string projectUniqueName, string projectFilePath, Guid projectGuid, object hierarchy, string binOutputPath)
IWorkspaceProjectContext IWorkspaceProjectContextFactory.CreateProjectContext(string languageName, string projectUniqueName, string projectFilePath, Guid projectGuid, object? hierarchy, string? binOutputPath)
{
return _threadingContext.JoinableTaskFactory.Run(() =>
this.CreateProjectContextAsync(languageName, projectUniqueName, projectFilePath, projectGuid, hierarchy, binOutputPath, assemblyName: null, CancellationToken.None));
}

IWorkspaceProjectContext IWorkspaceProjectContextFactory.CreateProjectContext(string languageName, string projectUniqueName, string projectFilePath, Guid projectGuid, object? hierarchy, string? binOutputPath, string? assemblyName)
{
return _threadingContext.JoinableTaskFactory.Run(() =>
this.CreateProjectContextAsync(languageName, projectUniqueName, projectFilePath, projectGuid, hierarchy, binOutputPath, CancellationToken.None));
this.CreateProjectContextAsync(languageName, projectUniqueName, projectFilePath, projectGuid, hierarchy, binOutputPath, assemblyName, CancellationToken.None));
}

public async Task<IWorkspaceProjectContext> CreateProjectContextAsync(
string languageName,
string projectUniqueName,
string projectFilePath,
string? projectFilePath,
Guid projectGuid,
object hierarchy,
string binOutputPath,
object? hierarchy,
string? binOutputPath,
string? assemblyName,
CancellationToken cancellationToken)
{
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

var creationInfo = new VisualStudioProjectCreationInfo
{
AssemblyName = assemblyName,
FilePath = projectFilePath,
Hierarchy = hierarchy as IVsHierarchy,
ProjectGuid = projectGuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public bool LastDesignTimeBuildSucceeded
set => _visualStudioProject.HasAllInformation = value;
}

public CPSProject(VisualStudioProject visualStudioProject, VisualStudioWorkspaceImpl visualStudioWorkspace, IProjectCodeModelFactory projectCodeModelFactory, Guid projectGuid, string binOutputPath)
public CPSProject(VisualStudioProject visualStudioProject, VisualStudioWorkspaceImpl visualStudioWorkspace, IProjectCodeModelFactory projectCodeModelFactory, Guid projectGuid, string? binOutputPath)
{
_visualStudioProject = visualStudioProject;
_visualStudioWorkspace = visualStudioWorkspace;
Expand Down

0 comments on commit ce652d5

Please sign in to comment.