/
SolutionChanges.cs
56 lines (49 loc) · 1.76 KB
/
SolutionChanges.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis
{
public struct SolutionChanges
{
private readonly Solution _newSolution;
private readonly Solution _oldSolution;
internal SolutionChanges(Solution newSolution, Solution oldSolution)
{
_newSolution = newSolution;
_oldSolution = oldSolution;
}
public IEnumerable<Project> GetAddedProjects()
{
foreach (var id in _newSolution.ProjectIds)
{
if (!_oldSolution.ContainsProject(id))
{
yield return _newSolution.GetProject(id);
}
}
}
public IEnumerable<ProjectChanges> GetProjectChanges()
{
var old = _oldSolution;
// if the project states are different then there is a change.
foreach (var id in _newSolution.ProjectIds)
{
var newState = _newSolution.GetProjectState(id);
var oldState = old.GetProjectState(id);
if (oldState != null && newState != null && newState != oldState)
{
yield return _newSolution.GetProject(id).GetChanges(_oldSolution.GetProject(id));
}
}
}
public IEnumerable<Project> GetRemovedProjects()
{
foreach (var id in _oldSolution.ProjectIds)
{
if (!_newSolution.ContainsProject(id))
{
yield return _oldSolution.GetProject(id);
}
}
}
}
}