dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.99k stars 4.03k forks source link

Add GeneratedFilesOutputDirectory to Solution APIs #75389

Open tmat opened 1 week ago

tmat commented 1 week ago

Background and Motivation

Add APIs to the Project and Solution that expose the value of CompilerGeneratedFilesOutputPath msbuild property from the solution snapshot.

See https://github.com/dotnet/roslyn/issues/75387

Proposed API

public readonly struct CompilationOutputInfo
{
    public string? AssemblyPath { get; }

+   public string? GeneratedFilesOutputDirectory { get; }
+   public CompilationOutputInfo WithGeneratedFilesOutputDirectory(string? path);
}

Usage Examples

Alternative Designs

namespace Microsoft.CodeAnalysis;

public class Project
{
+    /// <summary>
+    /// The path to the root directory of source generated files, or null if it is not known.
+    /// </summary>
+    public string? GeneratedFilesOutputDirectory { get; }
}

public class ProjectInfo
{
+    public string? GeneratedFilesOutputDirectory;
+    public ProjectInfo WithGeneratedFilesOutputDirectory(string? path);
}

public class Solution
{
+    public Solution WithProjectGeneratedFilesOutputDirectory(ProjectId projectId, string? path);
}

public class Workspace
{
+    protected internal void OnGeneratedFilesOutputDirectoryChanged(ProjectId projectId, string? outputFilePath);
}

Risks

333fred commented 1 week ago

API Review

Conclusion: API is approved