-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transitive ProjectReferences not considered during compilation #49731
Comments
This behavior is "By Design". The reason the solution builds in the setup you described is because of a feature in MSBuild where they pass the transitive set of references to the compiler. The compiler by explicit design does consider transitive references when building the compilation. |
@jaredpar I understand the design, and, as I mentioned in my original post, I'd say that — looked in isolation — it makes sense. However, this difference in behaviour poses a usability issue in the Roslyn API.
The compiler, itself, doesn't need to be changed; only the logic within a It's frustrating to see issues such as this one, whose compatibility use-case argument is obvious, being closed without a satisfactory explanation. In particular, in the area related to building, which is lacking in several aspects (e.g., |
I understand but the The appropriate layering of transitive references is on top of this model. Any component which wanted to apply transitive reference behavior could do a simple transform on the
I'm sorry you feel this is frustrating. But our model must support the full set of solutions that our customers have and many of those solutions include non-transitive references and all the quirks that come with it. |
First of all, thanks for the explanation @jaredpar . Yet, from all the technicality I could absorb — and based on the discussion in gitter (thanks @jnm2 and @CyrusNajmabadi too) —, I still see a possibility to deal with this issue. This is my suggestion:
@jaredpar , you say "… That includes cases where we do not have the full set of transitive references… ", but note that, the case in question, we're talking about a "project reference", whatever that is ( NOTEI have implemented a custom solution for this issue by manually collecting the transitive references, but the problem with this kind of approach is that, due to a subtle matter, it might break "tomorrow"; therefore, the need for an official solution. I have ~ a dozen workarounds in the area of project building (with/without |
I still retain some skepticism of whether this is the right layering. Have to deal with a lot of questions like do we respect the My biggest issue remains that at the core transitive references as most users understand them are an MSBuild concept while |
NOTE: Related to #3249.
Version Used: 3.8.0
Steps to Reproduce:
Consider libA.csproj, libB.csproj, and libC.csproj; all within proj.sln.
Project libC doesn't directly reference libA, but it references libB, which, in turn, references libA. Now, consider this snippet in
ClassC.cs
, inside libC.If I have 3
Microsoft.CodeAnalysis.Project
objects, whoseProjectReferences
mirror that setup I described above for the .csproj files, and compute theProject.GetCompilation
for theProject
object corresponding to libC, I get a diagnostic error for the use of libA within it.This related issue, from a few years ago, still is open and marked as a Question. In a strictly technical (and isolated) sense, I can understand that position. However — and back to this case —, given that same proj.sln/libC.csproj builds successfully, out-of-the box, from:
I'd consider this issue to be a bug.
The text was updated successfully, but these errors were encountered: