Skip to content

Add DisableTransitiveProjectReferences property - #155

Merged
dfederm merged 6 commits into
dfederm:mainfrom
lanaivkovic:fix/compilervisible-disable-transitive
Oct 13, 2026
Merged

dfederm merged 6 commits into
dfederm:mainfrom
lanaivkovic:fix/compilervisible-disable-transitive

Conversation

@lanaivkovic

@lanaivkovic lanaivkovic commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When DisableTransitiveProjectReferences is set to true, MSBuild does not automatically provide dependencies through another ProjectReference. Each project must directly reference every assembly required during compilation.

ReferenceTrimmer may incorrectly report such a direct reference as unused when the referenced assembly is not explicitly used in the source code but is still required by the compiler. The compiler may need to load types from another assembly while examining extension-method candidates, even when that extension method is ultimately rejected and a method from a different assembly is selected.
Issue log: #154

Solution

Added DisableTransitiveProjectReferences to CompilerVisibleProperty, allowing ReferenceTrimmer to receive the actual MSBuild property value and apply the correct project-reference logic.

An end-to-end test was added to verify the behavior with transitive project references both enabled and disabled.

Example

The test contains three projects: Library, Provider, and Dependency.

Provider exposes an extension method whose signature contains a type from Dependency. Library imports the Provider namespace but calls Linq's (other direct dependency of Library) ToArray() method instead.

Although the extension method from Provider is not selected, the compiler still requires Dependency.dll to inspect its signature and reject it as an invalid candidate.

Impact

Without this test coverage, ReferenceTrimmer could recommend removing a required project reference. When transitive project references are disabled, this could make a required DLL unavailable to the compiler and cause the project to fail to build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants