Skip to content

Commit

Permalink
Add a property to pass through the initial assembly name
Browse files Browse the repository at this point in the history
Right now we don't get the command line string for options until the
full design time build has completed; however the project system can
still give us the evaluated string which is likely to be close
enough. This allows features that want to get symbol names for source
to have a better chance of having something that they can use and
look up in caches or in the cloud.
  • Loading branch information
jasonmalinowski committed May 27, 2021
1 parent 5c9bcea commit bb7f615
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 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 @@ -17,6 +17,10 @@ internal interface IWorkspaceProjectContextFactory
[Obsolete("Use CreateProjectContextAsync instead")]
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
/// cref="IWorkspaceProjectContext"/> to lazily initialize the properties and items for the
Expand All @@ -29,6 +33,14 @@ internal interface IWorkspaceProjectContextFactory
/// <param name="projectGuid">Project guid.</param>
/// <param name="hierarchy">Obsolete. The argument is ignored.</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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ public CPSProjectFactory(
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, CancellationToken.None));
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, assemblyName, CancellationToken.None));
}

public async Task<IWorkspaceProjectContext> CreateProjectContextAsync(
Expand All @@ -54,12 +60,14 @@ public async Task<IWorkspaceProjectContext> CreateProjectContextAsync(
Guid projectGuid,
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

0 comments on commit bb7f615

Please sign in to comment.