I'm using Roslyn to look at a project that references a number of System assemblies, like this:
var workspace = MSBuildWorkspace.Create();
_solution = workspace.OpenSolutionAsync(_solutionPath).Result;
var project = _solution.Projects.Single(p => p.Name == "TestProject");
When I look at project.MetadataReferences it has 9 elements and project.ProjectReferences has no elements - all as I'd expect. The Documents property contains one more document than I'd expect, a generated document.
If I add a reference from this project to another, then project.ProjectReferences has one element, as I'd expect, but project.MetadataReferences has no references and hundreds of diagnostic errors due to missing System types. The generated document is not there.
The only change is adding the project reference. Why would all the metadata references disappear?