提交 94a44ead 编写于 作者: D Dustin Campbell

Add Project.OutputRefFilePath and ProjectInfo.OutputRefFilePath

This change adds an OutputRefFilePath path to the workspace API for the compiler's /refout feature.
上级 6d6fcc07
*REMOVED*static Microsoft.CodeAnalysis.ProjectInfo.Create(Microsoft.CodeAnalysis.ProjectId id, Microsoft.CodeAnalysis.VersionStamp version, string name, string assemblyName, string language, string filePath = null, string outputFilePath = null, Microsoft.CodeAnalysis.CompilationOptions compilationOptions = null, Microsoft.CodeAnalysis.ParseOptions parseOptions = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.DocumentInfo> documents = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.ProjectReference> projectReferences = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.MetadataReference> metadataReferences = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Diagnostics.AnalyzerReference> analyzerReferences = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.DocumentInfo> additionalDocuments = null, bool isSubmission = false, System.Type hostObjectType = null) -> Microsoft.CodeAnalysis.ProjectInfo
Microsoft.CodeAnalysis.Project.OutputRefFilePath.get -> string
Microsoft.CodeAnalysis.ProjectInfo.OutputRefFilePath.get -> string
Microsoft.CodeAnalysis.ProjectInfo.WithOutputRefFilePath(string outputRefFilePath) -> Microsoft.CodeAnalysis.ProjectInfo
Microsoft.CodeAnalysis.Solution.WithProjectOutputRefFilePath(Microsoft.CodeAnalysis.ProjectId projectId, string outputRefFilePath) -> Microsoft.CodeAnalysis.Solution
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.ConstantName = "constant name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.EnumMemberName = "enum member name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.EventName = "event name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.ExtensionMethodName = "extension method name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.FieldName = "field name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.ConstantName = "constant name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.LocalName = "local name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.ParameterName = "parameter name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.MethodName = "method name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.ExtensionMethodName = "extension method name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.ParameterName = "parameter name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.PropertyName = "property name" -> string
const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.EventName = "event name" -> string
\ No newline at end of file
static Microsoft.CodeAnalysis.ProjectInfo.Create(Microsoft.CodeAnalysis.ProjectId id, Microsoft.CodeAnalysis.VersionStamp version, string name, string assemblyName, string language, string filePath = null, string outputFilePath = null, Microsoft.CodeAnalysis.CompilationOptions compilationOptions = null, Microsoft.CodeAnalysis.ParseOptions parseOptions = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.DocumentInfo> documents = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.ProjectReference> projectReferences = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.MetadataReference> metadataReferences = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Diagnostics.AnalyzerReference> analyzerReferences = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.DocumentInfo> additionalDocuments = null, bool isSubmission = false, System.Type hostObjectType = null, string outputRefFilePath = null) -> Microsoft.CodeAnalysis.ProjectInfo
static Microsoft.CodeAnalysis.ProjectInfo.Create(Microsoft.CodeAnalysis.ProjectId id, Microsoft.CodeAnalysis.VersionStamp version, string name, string assemblyName, string language, string filePath, string outputFilePath, Microsoft.CodeAnalysis.CompilationOptions compilationOptions, Microsoft.CodeAnalysis.ParseOptions parseOptions, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.DocumentInfo> documents, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.ProjectReference> projectReferences, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.MetadataReference> metadataReferences, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Diagnostics.AnalyzerReference> analyzerReferences, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.DocumentInfo> additionalDocuments, bool isSubmission, System.Type hostObjectType) -> Microsoft.CodeAnalysis.ProjectInfo
......@@ -57,6 +57,11 @@ internal Project(Solution solution, ProjectState projectState)
/// </summary>
public string OutputFilePath => _projectState.OutputFilePath;
/// <summary>
/// The path to the reference assembly output file, or null if it is not known.
/// </summary>
public string OutputRefFilePath => _projectState.OutputRefFilePath;
/// <summary>
/// <code>true</code> if this <see cref="Project"/> supports providing data through the
/// <see cref="GetCompilationAsync(CancellationToken)"/> method.
......
......@@ -53,6 +53,11 @@ public sealed class ProjectInfo
/// </summary>
public string OutputFilePath => Attributes.OutputFilePath;
/// <summary>
/// The path to the reference assembly output file.
/// </summary>
public string OutputRefFilePath => Attributes.OutputRefFilePath;
/// <summary>
/// True if this is a submission project for interactive sessions.
/// </summary>
......@@ -138,6 +143,7 @@ public sealed class ProjectInfo
string language,
string filePath,
string outputFilePath,
string outputRefFilePath,
CompilationOptions compilationOptions,
ParseOptions parseOptions,
IEnumerable<DocumentInfo> documents,
......@@ -158,6 +164,7 @@ public sealed class ProjectInfo
language,
filePath,
outputFilePath,
outputRefFilePath,
isSubmission,
hasAllInformation),
compilationOptions,
......@@ -170,6 +177,35 @@ public sealed class ProjectInfo
hostObjectType);
}
// <Previous release> BACKCOMPAT OVERLOAD -- DO NOT TOUCH
/// <summary>
/// Create a new instance of a ProjectInfo.
/// </summary>
public static ProjectInfo Create(
ProjectId id,
VersionStamp version,
string name,
string assemblyName,
string language,
string filePath,
string outputFilePath,
CompilationOptions compilationOptions,
ParseOptions parseOptions,
IEnumerable<DocumentInfo> documents,
IEnumerable<ProjectReference> projectReferences,
IEnumerable<MetadataReference> metadataReferences,
IEnumerable<AnalyzerReference> analyzerReferences,
IEnumerable<DocumentInfo> additionalDocuments,
bool isSubmission,
Type hostObjectType)
{
return Create(
id, version, name, assemblyName, language,
filePath, outputFilePath, outputRefFilePath: null, compilationOptions, parseOptions,
documents, projectReferences, metadataReferences, analyzerReferences, additionalDocuments,
isSubmission, hostObjectType, hasAllInformation: true);
}
/// <summary>
/// Create a new instance of a ProjectInfo.
/// </summary>
......@@ -189,11 +225,12 @@ public sealed class ProjectInfo
IEnumerable<AnalyzerReference> analyzerReferences = null,
IEnumerable<DocumentInfo> additionalDocuments = null,
bool isSubmission = false,
Type hostObjectType = null)
Type hostObjectType = null,
string outputRefFilePath = null)
{
return Create(
id, version, name, assemblyName, language,
filePath, outputFilePath, compilationOptions, parseOptions,
filePath, outputFilePath, outputRefFilePath, compilationOptions, parseOptions,
documents, projectReferences, metadataReferences, analyzerReferences, additionalDocuments,
isSubmission, hostObjectType, hasAllInformation: true);
}
......@@ -233,15 +270,15 @@ public sealed class ProjectInfo
}
return new ProjectInfo(
newAttributes,
newCompilationOptions,
newParseOptions,
newDocuments,
newProjectReferences,
newMetadataReferences,
newAnalyzerReferences,
newAdditionalDocuments,
newHostObjectType);
newAttributes,
newCompilationOptions,
newParseOptions,
newDocuments,
newProjectReferences,
newMetadataReferences,
newAnalyzerReferences,
newAdditionalDocuments,
newHostObjectType);
}
public ProjectInfo WithDocuments(IEnumerable<DocumentInfo> documents)
......@@ -279,6 +316,11 @@ public ProjectInfo WithOutputFilePath(string outputFilePath)
return With(attributes: Attributes.With(outputPath: outputFilePath));
}
public ProjectInfo WithOutputRefFilePath(string outputRefFilePath)
{
return With(attributes: Attributes.With(outputRefPath: outputRefFilePath));
}
public ProjectInfo WithCompilationOptions(CompilationOptions compilationOptions)
{
return With(compilationOptions: compilationOptions);
......@@ -355,6 +397,11 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
/// </summary>
public string OutputFilePath { get; }
/// <summary>
/// The path to the reference assembly output file.
/// </summary>
public string OutputRefFilePath { get; }
/// <summary>
/// True if this is a submission project for interactive sessions.
/// </summary>
......@@ -375,6 +422,7 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
string language,
string filePath,
string outputFilePath,
string outputRefFilePath,
bool isSubmission,
bool hasAllInformation)
{
......@@ -386,6 +434,7 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
Version = version;
FilePath = filePath;
OutputFilePath = outputFilePath;
OutputRefFilePath = outputRefFilePath;
IsSubmission = isSubmission;
HasAllInformation = hasAllInformation;
}
......@@ -397,6 +446,7 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
string language = null,
Optional<string> filePath = default,
Optional<string> outputPath = default,
Optional<string> outputRefPath = default,
Optional<bool> isSubmission = default,
Optional<bool> hasAllInformation = default)
{
......@@ -406,6 +456,7 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
var newLanguage = language ?? Language;
var newFilepath = filePath.HasValue ? filePath.Value : FilePath;
var newOutputPath = outputPath.HasValue ? outputPath.Value : OutputFilePath;
var newOutputRefPath = outputRefPath.HasValue ? outputRefPath.Value : OutputRefFilePath;
var newIsSubmission = isSubmission.HasValue ? isSubmission.Value : IsSubmission;
var newHasAllInformation = hasAllInformation.HasValue ? hasAllInformation.Value : HasAllInformation;
......@@ -415,6 +466,7 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
newLanguage == Language &&
newFilepath == FilePath &&
newOutputPath == OutputFilePath &&
newOutputRefPath == OutputRefFilePath &&
newIsSubmission == IsSubmission &&
newHasAllInformation == HasAllInformation)
{
......@@ -422,15 +474,16 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
}
return new ProjectAttributes(
Id,
newVersion,
newName,
newAssemblyName,
newLanguage,
newFilepath,
newOutputPath,
newIsSubmission,
newHasAllInformation);
Id,
newVersion,
newName,
newAssemblyName,
newLanguage,
newFilepath,
newOutputPath,
newOutputRefPath,
newIsSubmission,
newHasAllInformation);
}
public void WriteTo(ObjectWriter writer)
......@@ -445,6 +498,7 @@ public void WriteTo(ObjectWriter writer)
writer.WriteString(Language);
writer.WriteString(FilePath);
writer.WriteString(OutputFilePath);
writer.WriteString(OutputRefFilePath);
writer.WriteBoolean(IsSubmission);
writer.WriteBoolean(HasAllInformation);
......@@ -462,10 +516,11 @@ public static ProjectAttributes ReadFrom(ObjectReader reader)
var language = reader.ReadString();
var filePath = reader.ReadString();
var outputFilePath = reader.ReadString();
var outputRefFilePath = reader.ReadString();
var isSubmission = reader.ReadBoolean();
var hasAllInformation = reader.ReadBoolean();
return new ProjectAttributes(projectId, VersionStamp.Create(), name, assemblyName, language, filePath, outputFilePath, isSubmission, hasAllInformation);
return new ProjectAttributes(projectId, VersionStamp.Create(), name, assemblyName, language, filePath, outputFilePath, outputRefFilePath, isSubmission, hasAllInformation);
}
private Checksum _lazyChecksum;
......
......@@ -265,6 +265,9 @@ public async Task<VersionStamp> GetSemanticVersionAsync(CancellationToken cancel
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public string OutputFilePath => this.ProjectInfo.OutputFilePath;
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public string OutputRefFilePath => this.ProjectInfo.OutputRefFilePath;
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
public HostLanguageServices LanguageServices => _languageServices;
......@@ -411,6 +414,16 @@ public ProjectState UpdateOutputPath(string outputFilePath)
return this.With(projectInfo: this.ProjectInfo.WithOutputFilePath(outputFilePath).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState UpdateOutputRefPath(string outputRefFilePath)
{
if (outputRefFilePath == this.OutputRefFilePath)
{
return this;
}
return this.With(projectInfo: this.ProjectInfo.WithOutputFilePath(outputRefFilePath).WithVersion(this.Version.GetNewerVersion()));
}
public ProjectState UpdateCompilationOptions(CompilationOptions options)
{
if (options == this.CompilationOptions)
......
......@@ -293,6 +293,20 @@ public Solution WithProjectOutputFilePath(ProjectId projectId, string outputFile
return new Solution(newState);
}
/// <summary>
/// Creates a new solution instance with the project specified updated to have the reference assembly output file path.
/// </summary>
public Solution WithProjectOutputRefFilePath(ProjectId projectId, string outputRefFilePath)
{
var newState = _state.WithProjectOutputRefFilePath(projectId, outputRefFilePath);
if (newState == _state)
{
return this;
}
return new Solution(newState);
}
/// <summary>
/// Creates a new solution instance with the project specified updated to have the name.
/// </summary>
......
......@@ -606,6 +606,21 @@ public SolutionState WithProjectOutputFilePath(ProjectId projectId, string outpu
return this.ForkProject(this.GetProjectState(projectId).UpdateOutputPath(outputFilePath));
}
/// <summary>
/// Creates a new solution instance with the project specified updated to have the output file path.
/// </summary>
public SolutionState WithProjectOutputRefFilePath(ProjectId projectId, string outputRefFilePath)
{
if (projectId == null)
{
throw new ArgumentNullException(nameof(projectId));
}
CheckContainsProject(projectId);
return this.ForkProject(this.GetProjectState(projectId).UpdateOutputRefPath(outputRefFilePath));
}
/// <summary>
/// Creates a new solution instance with the project specified updated to have the name.
/// </summary>
......
......@@ -1017,6 +1017,11 @@ private static Solution UpdateReferencesAfterAdd(Solution solution)
{
outputAssemblyToProjectIdMap[p.OutputFilePath] = p.Id;
}
if (!string.IsNullOrEmpty(p.OutputRefFilePath))
{
outputAssemblyToProjectIdMap[p.OutputRefFilePath] = p.Id;
}
}
// now fix each project if necessary
......@@ -1427,7 +1432,10 @@ private ProjectInfo CreateProjectInfo(Project project)
project.ProjectReferences,
project.MetadataReferences,
project.AnalyzerReferences,
project.AdditionalDocuments.Select(d => CreateDocumentInfoWithText(d)));
project.AdditionalDocuments.Select(d => CreateDocumentInfoWithText(d)),
project.IsSubmission,
project.State.HostObjectType,
project.OutputRefFilePath);
}
internal SourceText GetTextForced(TextDocument doc)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册