Repository navigation
Add DisableTransitiveProjectReferences property - #155
Merged
dfederm merged 6 commits intoOct 13, 2026
Merged
Conversation
Added a test for disabling transitive project references to verify that the correct warnings are generated based on the project configuration.
…ndidate whose signature depends on a transitively referenced project.
lanaivkovic
marked this pull request as ready for review
October 9, 2026 11:26
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andDependency.Providerexposes an extension method whose signature contains a type fromDependency.Libraryimports theProvidernamespace but calls Linq's (other direct dependency of Library)ToArray()method instead.Although the extension method from
Provideris not selected, the compiler still requiresDependency.dllto 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.