aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Link/SymbolWithSection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Link/SymbolWithSection.cs')
-rw-r--r--src/WixToolset.Core/Link/SymbolWithSection.cs91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/WixToolset.Core/Link/SymbolWithSection.cs b/src/WixToolset.Core/Link/SymbolWithSection.cs
new file mode 100644
index 00000000..c8934d0f
--- /dev/null
+++ b/src/WixToolset.Core/Link/SymbolWithSection.cs
@@ -0,0 +1,91 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Core.Link
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Linq;
8 using WixToolset.Data;
9
10 /// <summary>
11 /// Symbol with section representing a single unique symbol.
12 /// </summary>
13 internal class SymbolWithSection
14 {
15 private HashSet<SymbolWithSection> possibleConflicts;
16 private HashSet<SymbolWithSection> redundants;
17
18 /// <summary>
19 /// Creates a symbol for a symbol.
20 /// </summary>
21 /// <param name="symbol">Symbol for the symbol</param>
22 public SymbolWithSection(IntermediateSection section, IntermediateSymbol symbol)
23 {
24 this.Symbol = symbol;
25 this.Section = section;
26 this.Name = String.Concat(this.Symbol.Definition.Name, ":", this.Symbol.Id.Id);
27 }
28
29 /// <summary>
30 /// Gets the accessibility of the symbol which is a direct reflection of the accessibility of the row's accessibility.
31 /// </summary>
32 /// <value>Accessbility of the symbol.</value>
33 public AccessModifier Access => this.Symbol.Id.Access;
34
35 /// <summary>
36 /// Gets the name of the symbol.
37 /// </summary>
38 /// <value>Name of the symbol.</value>
39 public string Name { get; }
40
41 /// <summary>
42 /// Gets the symbol for this symbol.
43 /// </summary>
44 /// <value>Symbol for this symbol.</value>
45 public IntermediateSymbol Symbol { get; }
46
47 /// <summary>
48 /// Gets the section for the symbol.
49 /// </summary>
50 /// <value>Section for the symbol.</value>
51 public IntermediateSection Section { get; }
52
53 /// <summary>
54 /// Gets any duplicates of this symbol with sections that are possible conflicts.
55 /// </summary>
56 public IEnumerable<SymbolWithSection> PossiblyConflicts => this.possibleConflicts ?? Enumerable.Empty<SymbolWithSection>();
57
58 /// <summary>
59 /// Gets any duplicates of this symbol with sections that are redundant.
60 /// </summary>
61 public IEnumerable<SymbolWithSection> Redundants => this.redundants ?? Enumerable.Empty<SymbolWithSection>();
62
63 /// <summary>
64 /// Adds a duplicate symbol with sections that is a possible conflict.
65 /// </summary>
66 /// <param name="symbolWithSection">Symbol with section that is a possible conflict of this symbol.</param>
67 public void AddPossibleConflict(SymbolWithSection symbolWithSection)
68 {
69 if (null == this.possibleConflicts)
70 {
71 this.possibleConflicts = new HashSet<SymbolWithSection>();
72 }
73
74 this.possibleConflicts.Add(symbolWithSection);
75 }
76
77 /// <summary>
78 /// Adds a duplicate symbol that is redundant.
79 /// </summary>
80 /// <param name="symbolWithSection">Symbol with section that is redundant of this symbol.</param>
81 public void AddRedundant(SymbolWithSection symbolWithSection)
82 {
83 if (null == this.redundants)
84 {
85 this.redundants = new HashSet<SymbolWithSection>();
86 }
87
88 this.redundants.Add(symbolWithSection);
89 }
90 }
91}