diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a8f1332ef..9beca678ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- [CLI] Reference the compiled output of referenced projects that cannot be loaded into the workspace (for example F# projects), so their types are no longer reported as missing (`CS0103`/`CS0246`) during analysis ([PR](https://github.com/dotnet/roslynator/pull/1833)) + ## [5.0.0] - 2026-08-21 ### Added diff --git a/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs b/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs index ac6d504cd9..fb6006cc87 100644 --- a/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs +++ b/src/CommandLine/Commands/MSBuildWorkspaceCommand.cs @@ -282,7 +282,15 @@ private static MSBuildWorkspace CreateMSBuildWorkspace(string msbuildPath, IEnum if (!properties.ContainsKey("AlwaysCompileMarkupFilesInSeparateDomain")) properties["AlwaysCompileMarkupFilesInSeparateDomain"] = bool.FalseString; - return MSBuildWorkspace.Create(properties); + MSBuildWorkspace workspace = MSBuildWorkspace.Create(properties); + + // Fall back to a referenced project's compiled output when the project itself cannot be + // loaded into the workspace (for example an F# project, which MSBuildWorkspace does not + // support). Without this, types defined in such a project are invisible to the C#/VB + // projects that reference it and surface as false CS0246/CS0103 errors during analysis. + workspace.LoadMetadataForReferencedProjects = true; + + return workspace; } private static bool TryGetVisualStudioInstance(out VisualStudioInstance result)