dotnet/roslyn

[MSBuildWorkspace] ProjectReferences vs. AllProjectReferences return the same count despite projects not existing in the solution.

開放

#46,113 建立於 2020年7月17日

 (1 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-IDEConcept-Continuous ImprovementIDE-MSBuildWorkspacehelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

Version Used: master, 16.6.0, etc

Steps to Reproduce:

  1. Create a project A and a project B
  2. Have A reference B
  3. Create a solution X and add only A to it
  4. Use MSBuildWorkspace and OpenSolutionAsync()
  5. Compare A's ProjectReferences to AllProjectReferences

Expected Behavior:

They should be different, because solution X only has A in it.

Actual Behavior:

They are the same because the way a solution is loaded causes project references to be loaded into it even if they're not actually in the solution. See here:

https://github.com/dotnet/roslyn/blob/2a69ac38995a07f4333158b76d2f6e780868401a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs#L138-L172

貢獻者指南