dotnet / project-system

The .NET Project System for Visual Studio
MIT License
969 stars 387 forks source link

New transitive dependency tree items may not appear if parent already created with no children #6484

Open Varorbc opened 4 years ago

Varorbc commented 4 years ago

Visual Studio Version:16.8.0 preview 1.0

Summary:

image

Steps to Reproduce:


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj" />
  </ItemGroup>

</Project>

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <PackageId>Test</PackageId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  </ItemGroup>

</Project>
davkean commented 4 years ago

tag @drewnoakes

drewnoakes commented 4 years ago

I can repro this in Version 16.8.0 Preview 2.0 [30410.76.master], but only under very specific conditions:

  1. Create the empty parent project
  2. Create the empty child project
  3. Add a P2P reference from parent to child
  4. Expand the dependencies tree in the parent so you can see the child project reference, which will have no children
  5. Add the package reference to the child project, and the parent's tree will not reflect that

Not pre-expanding the parent tree causes it to show. Reloading the project/solution causes it to show. Removing the project reference and re-adding it causes it to show.

My assumption is that the attached collection is being lazily created in such a way as to not receive future updates when they arrive. Note though that once the node has children, future children can be added without problem.

Potentially relevant code: https://github.com/NuGet/NuGet.Client/pull/3392/files#diff-a5a55c7613fcaf2f4fbe63fbcfa1eb7cR45

Varorbc commented 4 years ago

@drewnoakes

  1. Create the empty parent project
  2. Create the empty child project

This problem also exists for non-empty projects

drewnoakes commented 4 years ago

@Varorbc those are minimal steps to repro the problem.

drewnoakes commented 8 months ago

This still repros.