-
Notifications
You must be signed in to change notification settings - Fork 4k
/
ProjectReference.cs
78 lines (64 loc) · 2.54 KB
/
ProjectReference.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 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;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis
{
[DebuggerDisplay("{GetDebuggerDisplay(),nq}")]
public sealed class ProjectReference : IEquatable<ProjectReference>
{
private readonly ProjectId _projectId;
private readonly ImmutableArray<string> _aliases;
private readonly bool _embedInteropTypes;
public ProjectReference(ProjectId projectId, ImmutableArray<string> aliases = default, bool embedInteropTypes = false)
{
Contract.ThrowIfNull(projectId);
_projectId = projectId;
_aliases = aliases.NullToEmpty();
_embedInteropTypes = embedInteropTypes;
}
public ProjectId ProjectId => _projectId;
/// <summary>
/// Aliases for the reference. Empty if the reference has no aliases.
/// </summary>
public ImmutableArray<string> Aliases => _aliases;
/// <summary>
/// True if interop types defined in the referenced project should be embedded into the referencing project.
/// </summary>
public bool EmbedInteropTypes => _embedInteropTypes;
public override bool Equals(object obj)
{
return this.Equals(obj as ProjectReference);
}
public bool Equals(ProjectReference reference)
{
if (ReferenceEquals(this, reference))
{
return true;
}
return !ReferenceEquals(reference, null) &&
_projectId == reference._projectId &&
_aliases.SequenceEqual(reference._aliases) &&
_embedInteropTypes == reference._embedInteropTypes;
}
public static bool operator ==(ProjectReference left, ProjectReference right)
{
return EqualityComparer<ProjectReference>.Default.Equals(left, right);
}
public static bool operator !=(ProjectReference left, ProjectReference right)
{
return !(left == right);
}
public override int GetHashCode()
{
return Hash.CombineValues(_aliases, Hash.Combine(_projectId, _embedInteropTypes.GetHashCode()));
}
private string GetDebuggerDisplay()
{
return _projectId.ToString();
}
}
}