Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,6 @@ namespace Microsoft.VisualStudio.LanguageServices.ProjectSystem;
/// </summary>
internal interface IWorkspaceProjectContextFactory
{
/// <summary>
/// Creates and initializes a new Workspace project and returns a <see
/// cref="IWorkspaceProjectContext"/> to lazily initialize the properties and items for the
/// project. This method guarantees that either the project is added (and the returned task
/// completes) or cancellation is observed and no project is added.
/// </summary>
/// <param name="languageName">Project language.</param>
/// <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">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>
[Obsolete]
Task<IWorkspaceProjectContext> CreateProjectContextAsync(
string languageName,
string projectUniqueName,
string projectFilePath,
Guid projectGuid,
object? hierarchy,
string? binOutputPath,
string? assemblyName,
CancellationToken cancellationToken);

/// <summary>
/// Creates and initializes a new project and returns a <see
/// cref="IWorkspaceProjectContext"/> to lazily initialize the properties and items for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,58 +57,6 @@ public ImmutableArray<string> EvaluationPropertyNames
public ImmutableArray<string> EvaluationItemNames
=> BuildPropertyNames.InitialEvaluationItemNames;

// Kept around onyl for integration tests.
[Obsolete]
public Task<IWorkspaceProjectContext> CreateProjectContextAsync(
string languageName,
string projectUniqueName,
string? projectFilePath,
Guid projectGuid,
object? hierarchy,
string? binOutputPath,
string? assemblyName,
CancellationToken cancellationToken)
{
var data = new IntegrationTestEvaluationData(projectFilePath ?? "", projectFilePath ?? "", assemblyName ?? "", binOutputPath ?? "", "SHA256");
return CreateProjectContextAsync(projectGuid, projectUniqueName, languageName, data, hierarchy, cancellationToken);
}

[Obsolete]
internal sealed class IntegrationTestEvaluationData : EvaluationData
{
public string ProjectFilePath { get; }
public string TargetPath { get; }
public string AssemblyName { get; }
public string OutputAssembly { get; }
public string ChecksumAlgorithm { get; }

public IntegrationTestEvaluationData(string projectFilePath, string targetPath, string assemblyName, string outputAssembly, string checksumAlgorithm)
{
ProjectFilePath = projectFilePath;
TargetPath = targetPath;
AssemblyName = assemblyName;
OutputAssembly = outputAssembly;
ChecksumAlgorithm = checksumAlgorithm;
}

public override string GetPropertyValue(string name)
=> name switch
{
BuildPropertyNames.MSBuildProjectFullPath => ProjectFilePath,
BuildPropertyNames.TargetPath => TargetPath,
BuildPropertyNames.AssemblyName => AssemblyName,
BuildPropertyNames.CommandLineArgsForDesignTimeEvaluation => "-checksumalgorithm:" + ChecksumAlgorithm,
_ => throw ExceptionUtilities.UnexpectedValue(name)
};

public override ImmutableArray<string> GetItemValues(string name)
=> name switch
{
BuildPropertyNames.IntermediateAssembly => [OutputAssembly],
_ => throw ExceptionUtilities.UnexpectedValue(name)
};
}

public async Task<IWorkspaceProjectContext> CreateProjectContextAsync(Guid id, string uniqueName, string languageName, EvaluationData data, object? hostObject, CancellationToken cancellationToken)
{
// Read all required properties from EvaluationData before we start updating anything.
Expand Down Expand Up @@ -203,11 +151,13 @@ public async Task<IWorkspaceProjectContext> CreateProjectContextAsync(Guid id, s
const string itemName = BuildPropertyNames.IntermediateAssembly;

var values = data.GetItemValues(itemName);
if (values.Length != 1)
if (values.Length > 1)
{
var joinedValues = string.Join(";", values);
throw new InvalidProjectDataException(itemName, joinedValues, $"Item group '{itemName}' is required to specify a single value: '{joinedValues}'.");
}
else if (values.Length == 0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit suspicious to me that if we didn't get any back we'd throw an exception since that could be an error case...so going to change the logic a bit.

{
// TODO: Throw once we update integration tests to the latest VS (https://github.com/dotnet/roslyn/issues/65439)
// var joinedValues = string.Join(";", values);
// throw new InvalidProjectDataException(itemName, joinedValues, $"Item group '{itemName}' is required to specify a single value: '{joinedValues}'.");
return null;
}

Expand Down
Loading