public void Test_WorkspaceChanges()
        {
            var workspace = new TestWorkspace();
            var solution = workspace.CurrentSolution;
            var project1 = workspace.AddProject("P1");
            var graph = ProjectDependencyService.GetDependencyGraphAsync(workspace.CurrentSolution, CancellationToken.None).Result;
            var project2 = workspace.AddProject("P2");
            graph = ProjectDependencyService.GetDependencyGraphAsync(workspace.CurrentSolution, CancellationToken.None).Result;
            var sortedProjects = graph.GetTopologicallySortedProjects();
            AssertEx.SetEqual(sortedProjects, project1, project2);
            
            Project ps = workspace.CurrentSolution.GetProject(project1);
            int startCount = ps.MetadataReferences.Count;

            var source2 = @"
using System;
public class X
{
}
";
            MetadataReference comp1 = CreateCSharpCompilation(source2).ToMetadataReference();            
            workspace.OnMetadataReferenceAdded(project1, comp1);
            workspace.OnAssemblyNameChanged(project1, "ChangedP1");
            
            Assert.False(ps.CompilationOptions.CheckOverflow);
            CompilationOptions co = new CSharp.CSharpCompilationOptions(outputKind: OutputKind.DynamicallyLinkedLibrary, checkOverflow: true);            
            workspace.OnCompilationOptionsChanged(project1, co);
            
            ps = workspace.CurrentSolution.GetProject(project1);
            Assert.Equal(startCount + 1, ps.MetadataReferences.Count);
            Assert.Equal(ps.AssemblyName, "ChangedP1");
            Assert.True(ps.CompilationOptions.CheckOverflow);            
        }
        public void Test_WorkspaceChanges()
        {
            var workspace = new TestWorkspace();
            var solution  = workspace.CurrentSolution;
            var project1  = workspace.AddProject("P1");
            var graph     = ProjectDependencyService.GetDependencyGraphAsync(workspace.CurrentSolution, CancellationToken.None).Result;
            var project2  = workspace.AddProject("P2");

            graph = ProjectDependencyService.GetDependencyGraphAsync(workspace.CurrentSolution, CancellationToken.None).Result;
            var sortedProjects = graph.GetTopologicallySortedProjects();

            AssertEx.SetEqual(sortedProjects, project1, project2);

            Project ps         = workspace.CurrentSolution.GetProject(project1);
            int     startCount = ps.MetadataReferences.Count;

            var source2             = @"
using System;
public class X
{
}
";
            MetadataReference comp1 = CreateCSharpCompilation(source2).ToMetadataReference();

            workspace.OnMetadataReferenceAdded(project1, comp1);
            workspace.OnAssemblyNameChanged(project1, "ChangedP1");

            Assert.False(ps.CompilationOptions.CheckOverflow);
            CompilationOptions co = new CSharp.CSharpCompilationOptions(outputKind: OutputKind.DynamicallyLinkedLibrary, checkOverflow: true);

            workspace.OnCompilationOptionsChanged(project1, co);

            ps = workspace.CurrentSolution.GetProject(project1);
            Assert.Equal(startCount + 1, ps.MetadataReferences.Count);
            Assert.Equal(ps.AssemblyName, "ChangedP1");
            Assert.True(ps.CompilationOptions.CheckOverflow);
        }