From 634fc916f620ee46c1634327e66328fabb68c9d1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Jul 2020 13:16:30 -0700 Subject: Catch up a few files missed in the Great Tuple to Symbol rename --- src/WixToolset.Data/ISymbolDefinitionCreator.cs | 11 + src/WixToolset.Data/ITupleDefinitionCreator.cs | 11 - src/WixToolset.Data/IntermediateSymbol.cs | 256 +++++++++++++++++++ .../IntermediateSymbolDefinition.cs | 270 +++++++++++++++++++++ .../IntermediateSymbolExtensions.cs | 121 +++++++++ src/WixToolset.Data/IntermediateTuple.cs | 256 ------------------- src/WixToolset.Data/IntermediateTupleDefinition.cs | 270 --------------------- src/WixToolset.Data/IntermediateTupleExtensions.cs | 121 --------- src/WixToolset.Data/Section.cs | 242 ------------------ .../SimpleSymbolDefinitionCreator.cs | 31 +++ .../SimpleTupleDefinitionCreator.cs | 31 --- src/WixToolset.Data/SymbolWithSection.cs | 90 +++++++ src/WixToolset.Data/TupleWithSection.cs | 90 ------- 13 files changed, 779 insertions(+), 1021 deletions(-) create mode 100644 src/WixToolset.Data/ISymbolDefinitionCreator.cs delete mode 100644 src/WixToolset.Data/ITupleDefinitionCreator.cs create mode 100644 src/WixToolset.Data/IntermediateSymbol.cs create mode 100644 src/WixToolset.Data/IntermediateSymbolDefinition.cs create mode 100644 src/WixToolset.Data/IntermediateSymbolExtensions.cs delete mode 100644 src/WixToolset.Data/IntermediateTuple.cs delete mode 100644 src/WixToolset.Data/IntermediateTupleDefinition.cs delete mode 100644 src/WixToolset.Data/IntermediateTupleExtensions.cs delete mode 100644 src/WixToolset.Data/Section.cs create mode 100644 src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs delete mode 100644 src/WixToolset.Data/SimpleTupleDefinitionCreator.cs create mode 100644 src/WixToolset.Data/SymbolWithSection.cs delete mode 100644 src/WixToolset.Data/TupleWithSection.cs (limited to 'src') diff --git a/src/WixToolset.Data/ISymbolDefinitionCreator.cs b/src/WixToolset.Data/ISymbolDefinitionCreator.cs new file mode 100644 index 00000000..93b10ce8 --- /dev/null +++ b/src/WixToolset.Data/ISymbolDefinitionCreator.cs @@ -0,0 +1,11 @@ +// 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. + +namespace WixToolset.Data +{ + public interface ISymbolDefinitionCreator + { + void AddCustomSymbolDefinition(IntermediateSymbolDefinition definition); + + bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition); + } +} diff --git a/src/WixToolset.Data/ITupleDefinitionCreator.cs b/src/WixToolset.Data/ITupleDefinitionCreator.cs deleted file mode 100644 index 93b10ce8..00000000 --- a/src/WixToolset.Data/ITupleDefinitionCreator.cs +++ /dev/null @@ -1,11 +0,0 @@ -// 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. - -namespace WixToolset.Data -{ - public interface ISymbolDefinitionCreator - { - void AddCustomSymbolDefinition(IntermediateSymbolDefinition definition); - - bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition); - } -} diff --git a/src/WixToolset.Data/IntermediateSymbol.cs b/src/WixToolset.Data/IntermediateSymbol.cs new file mode 100644 index 00000000..4030df5d --- /dev/null +++ b/src/WixToolset.Data/IntermediateSymbol.cs @@ -0,0 +1,256 @@ +// 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. + +namespace WixToolset.Data +{ + using System; + using System.Diagnostics; + using SimpleJson; + + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class IntermediateSymbol + { + private object tags; + + public IntermediateSymbol(IntermediateSymbolDefinition definition) : this(definition, null, null) + { + } + + public IntermediateSymbol(IntermediateSymbolDefinition definition, SourceLineNumber sourceLineNumber, Identifier id = null) + { + this.Definition = definition; + this.Fields = new IntermediateField[definition.FieldDefinitions.Length]; + this.SourceLineNumbers = sourceLineNumber; + this.Id = id; + } + + public IntermediateSymbolDefinition Definition { get; } + + public IntermediateField[] Fields { get; } + + public SourceLineNumber SourceLineNumbers { get; set; } + + public Identifier Id { get; set; } + + public IntermediateField this[int index] => this.Fields[index]; + + private string DebuggerDisplay => $"{this.Definition?.Name} {this.Id?.Id}"; + + public bool AddTag(string add) + { + if (this.tags == null) + { + this.tags = add; + } + else if (this.tags is string tag) + { + if (tag == add) + { + return false; + } + + this.tags = new[] { tag, add }; + } + else + { + var tagsArray = (string[])this.tags; + var array = new string[tagsArray.Length + 1]; + + for (var i = 0; i < tagsArray.Length; ++i) + { + if (tagsArray[i] == add) + { + return false; + } + + array[i] = tagsArray[i]; + } + + array[tagsArray.Length] = add; + + this.tags = array; + } + + return true; + } + + public bool HasTag(string has) + { + if (this.tags == null) + { + return false; + } + else if (this.tags is string tag) + { + return tag == has; + } + else + { + foreach (var element in (string[])this.tags) + { + if (element == has) + { + return true; + } + } + } + + return false; + } + + public bool RemoveTag(string remove) + { + if (this.tags is string tag) + { + if (tag == remove) + { + this.tags = null; + return true; + } + } + else if (this.tags is string[] tagsArray) + { + if (tagsArray.Length == 2) + { + if (tagsArray[0] == remove) + { + this.tags = tagsArray[1]; + return true; + } + else if (tagsArray[1] == remove) + { + this.tags = tagsArray[0]; + return true; + } + } + else + { + var array = new string[tagsArray.Length - 1]; + var arrayIndex = 0; + var found = false; + + for (var i = 0; i < tagsArray.Length; ++i) + { + if (tagsArray[i] == remove) + { + found = true; + continue; + } + else if (arrayIndex == array.Length) + { + break; + } + + array[arrayIndex++] = tagsArray[i]; + } + + if (found) + { + this.tags = array; + return true; + } + } + } + + return false; + } + + internal static IntermediateSymbol Deserialize(ISymbolDefinitionCreator creator, Uri baseUri, JsonObject jsonObject) + { + var definitionName = jsonObject.GetValueOrDefault("type"); + var idJson = jsonObject.GetValueOrDefault("id"); + var sourceLineNumbersJson = jsonObject.GetValueOrDefault("ln"); + var fieldsJson = jsonObject.GetValueOrDefault("fields"); + var tagsJson = jsonObject.GetValueOrDefault("tags"); + + var id = (idJson == null) ? null : Identifier.Deserialize(idJson); + var sourceLineNumbers = (sourceLineNumbersJson == null) ? null : SourceLineNumber.Deserialize(sourceLineNumbersJson); + + // TODO: this isn't sufficient. + if (!creator.TryGetSymbolDefinitionByName(definitionName, out var definition)) + { + throw new WixException(ErrorMessages.UnknownSymbolType(definitionName)); + } + + var symbol = definition.CreateSymbol(sourceLineNumbers, id); + + for (var i = 0; i < fieldsJson.Count && i < symbol.Fields.Length; ++i) + { + if (fieldsJson[i] is JsonObject fieldJson) + { + symbol.Fields[i] = IntermediateField.Deserialize(symbol.Definition.FieldDefinitions[i], baseUri, fieldJson); + } + } + + if (tagsJson == null || tagsJson.Count == 0) + { + } + else if (tagsJson.Count == 1) + { + symbol.tags = (string)tagsJson[0]; + } + else + { + var tags = new string[tagsJson.Count]; + + for (var i = 0; i < tagsJson.Count; ++i) + { + tags[i] = (string)tagsJson[i]; + } + + symbol.tags = tags; + } + + return symbol; + } + + internal JsonObject Serialize() + { + var jsonObject = new JsonObject + { + { "type", this.Definition.Name } + }; + + var idJson = this.Id?.Serialize(); + if (idJson != null) + { + jsonObject.Add("id", idJson); + } + + var lnJson = this.SourceLineNumbers?.Serialize(); + if (lnJson != null) + { + jsonObject.Add("ln", lnJson); + } + + var fieldsJson = new JsonArray(this.Fields.Length); + + foreach (var field in this.Fields) + { + var fieldJson = field?.Serialize(); + fieldsJson.Add(fieldJson); + } + + jsonObject.Add("fields", fieldsJson); + + if (this.tags is string || this.tags is string[]) + { + JsonArray tagsJson; + + if (this.tags is string tag) + { + tagsJson = new JsonArray(1) { tag }; + } + else + { + var array = (string[])this.tags; + tagsJson = new JsonArray(array.Length); + tagsJson.AddRange(array); + } + + jsonObject.Add("tags", tagsJson); + } + + return jsonObject; + } + } +} diff --git a/src/WixToolset.Data/IntermediateSymbolDefinition.cs b/src/WixToolset.Data/IntermediateSymbolDefinition.cs new file mode 100644 index 00000000..102a9f5c --- /dev/null +++ b/src/WixToolset.Data/IntermediateSymbolDefinition.cs @@ -0,0 +1,270 @@ +// 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. + +namespace WixToolset.Data +{ + using System; + using SimpleJson; + + public class IntermediateSymbolDefinition + { + private object tags; + + public IntermediateSymbolDefinition(string name, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) + : this(SymbolDefinitionType.MustBeFromAnExtension, name, 0, fieldDefinitions, strongSymbolType) + { + } + + public IntermediateSymbolDefinition(string name, int revision, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) + : this(SymbolDefinitionType.MustBeFromAnExtension, name, revision, fieldDefinitions, strongSymbolType) + { + } + + internal IntermediateSymbolDefinition(SymbolDefinitionType type, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) + : this(type, type.ToString(), 0, fieldDefinitions, strongSymbolType) + { + } + + private IntermediateSymbolDefinition(SymbolDefinitionType type, string name, int revision, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) + { + this.Type = type; + this.Name = name; + this.Revision = revision; + this.FieldDefinitions = fieldDefinitions; + this.StrongSymbolType = strongSymbolType ?? typeof(IntermediateSymbol); +#if DEBUG + if (this.StrongSymbolType != typeof(IntermediateSymbol) && !this.StrongSymbolType.IsSubclassOf(typeof(IntermediateSymbol))) { throw new ArgumentException(nameof(strongSymbolType)); } +#endif + } + + public int Revision { get; } + + public SymbolDefinitionType Type { get; } + + public string Name { get; } + + public IntermediateFieldDefinition[] FieldDefinitions { get; } + + private Type StrongSymbolType { get; } + + public IntermediateSymbol CreateSymbol(SourceLineNumber sourceLineNumber = null, Identifier id = null) + { + var result = (this.StrongSymbolType == typeof(IntermediateSymbol)) ? (IntermediateSymbol)Activator.CreateInstance(this.StrongSymbolType, this) : (IntermediateSymbol)Activator.CreateInstance(this.StrongSymbolType); + result.SourceLineNumbers = sourceLineNumber; + result.Id = id; + + return result; + } + + public bool AddTag(string add) + { + if (this.tags == null) + { + this.tags = add; + } + else if (this.tags is string tag) + { + if (tag == add) + { + return false; + } + + this.tags = new[] { tag, add }; + } + else + { + var tagsArray = (string[])this.tags; + var array = new string[tagsArray.Length + 1]; + + for (var i = 0; i < tagsArray.Length; ++i) + { + if (tagsArray[i] == add) + { + return false; + } + + array[i] = tagsArray[i]; + } + + array[tagsArray.Length] = add; + + this.tags = array; + } + + return true; + } + + public bool HasTag(string has) + { + if (this.tags == null) + { + return false; + } + else if (this.tags is string tag) + { + return tag == has; + } + else + { + foreach (var element in (string[])this.tags) + { + if (element == has) + { + return true; + } + } + } + + return false; + } + + public bool RemoveTag(string remove) + { + if (this.tags is string tag) + { + if (tag == remove) + { + this.tags = null; + return true; + } + } + else if (this.tags is string[] tagsArray) + { + if (tagsArray.Length == 2) + { + if (tagsArray[0] == remove) + { + this.tags = tagsArray[1]; + return true; + } + else if (tagsArray[1] == remove) + { + this.tags = tagsArray[0]; + return true; + } + } + else + { + var array = new string[tagsArray.Length - 1]; + var arrayIndex = 0; + var found = false; + + for (var i = 0; i < tagsArray.Length; ++i) + { + if (tagsArray[i] == remove) + { + found = true; + continue; + } + else if (arrayIndex == array.Length) + { + break; + } + + array[arrayIndex++] = tagsArray[i]; + } + + if (found) + { + this.tags = array; + return true; + } + } + } + + return false; + } + + internal static IntermediateSymbolDefinition Deserialize(JsonObject jsonObject) + { + var name = jsonObject.GetValueOrDefault("name"); + var revision = jsonObject.GetValueOrDefault("rev", 0); + var definitionsJson = jsonObject.GetValueOrDefault("fields"); + var tagsJson = jsonObject.GetValueOrDefault("tags"); + + var fieldDefinitions = new IntermediateFieldDefinition[definitionsJson.Count]; + + for (var i = 0; i < definitionsJson.Count; ++i) + { + var definitionJson = (JsonObject)definitionsJson[i]; + var fieldName = definitionJson.GetValueOrDefault("name"); + var fieldType = definitionJson.GetEnumOrDefault("type", IntermediateFieldType.String); + fieldDefinitions[i] = new IntermediateFieldDefinition(fieldName, fieldType); + } + + var definition = new IntermediateSymbolDefinition(name, revision, fieldDefinitions, null); + + if (tagsJson == null || tagsJson.Count == 0) + { + } + else if (tagsJson.Count == 1) + { + definition.tags = (string)tagsJson[0]; + } + else + { + var tags = new string[tagsJson.Count]; + + for (var i = 0; i < tagsJson.Count; ++i) + { + tags[i] = (string)tagsJson[i]; + } + + definition.tags = tags; + } + + return definition; + } + + internal JsonObject Serialize() + { + var jsonObject = new JsonObject + { + { "name", this.Name } + }; + + if (this.Revision > 0) + { + jsonObject.Add("rev", this.Revision); + } + + var fieldsJson = new JsonArray(this.FieldDefinitions.Length); + + foreach (var fieldDefinition in this.FieldDefinitions) + { + var fieldJson = new JsonObject + { + { "name", fieldDefinition.Name }, + }; + + if (fieldDefinition.Type != IntermediateFieldType.String) + { + fieldJson.Add("type", fieldDefinition.Type.ToString().ToLowerInvariant()); + } + + fieldsJson.Add(fieldJson); + } + + jsonObject.Add("fields", fieldsJson); + + if (this.tags is string || this.tags is string[]) + { + JsonArray tagsJson; + + if (this.tags is string tag) + { + tagsJson = new JsonArray(1) { tag }; + } + else + { + var array = (string[])this.tags; + tagsJson = new JsonArray(array.Length); + tagsJson.AddRange(array); + } + + jsonObject.Add("tags", tagsJson); + } + + return jsonObject; + } + } +} diff --git a/src/WixToolset.Data/IntermediateSymbolExtensions.cs b/src/WixToolset.Data/IntermediateSymbolExtensions.cs new file mode 100644 index 00000000..10f0d7f0 --- /dev/null +++ b/src/WixToolset.Data/IntermediateSymbolExtensions.cs @@ -0,0 +1,121 @@ +// 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. + +namespace WixToolset.Data +{ + public static class IntermediateSymbolExtensions + { + public static bool AsBool(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsBool() ?? false; + + public static bool? AsNullableBool(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNullableBool(); + + public static int AsNumber(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNumber() ?? 0; + + public static int? AsNullableNumber(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNullableNumber(); + + public static string AsString(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsString(); + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, bool value) + { + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, bool? value) + { + if (value == null && NoFieldMetadata(symbol, index)) + { + return symbol.Fields[index] = null; + } + + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, long value) + { + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, long? value) + { + if (value == null && NoFieldMetadata(symbol, index)) + { + return symbol.Fields[index] = null; + } + + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, int value) + { + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, int? value) + { + if (value == null && NoFieldMetadata(symbol, index)) + { + return symbol.Fields[index] = null; + } + + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, IntermediateFieldPathValue value) + { + if (value?.Path == null && value?.BaseUri == null && NoFieldMetadata(symbol, index)) + { + return symbol.Fields[index] = null; + } + + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + public static IntermediateField Set(this IntermediateSymbol symbol, int index, string value) + { + if (value == null && NoFieldMetadata(symbol, index)) + { + return symbol.Fields[index] = null; + } + + var definition = symbol.Definition.FieldDefinitions[index]; + + var field = symbol.Fields[index].Set(definition, value); + + return symbol.Fields[index] = field; + } + + private static bool NoFieldMetadata(IntermediateSymbol symbol, int index) + { + var field = symbol?.Fields[index]; + + return field?.Context == null && field?.PreviousValue == null; + } + } +} diff --git a/src/WixToolset.Data/IntermediateTuple.cs b/src/WixToolset.Data/IntermediateTuple.cs deleted file mode 100644 index 4030df5d..00000000 --- a/src/WixToolset.Data/IntermediateTuple.cs +++ /dev/null @@ -1,256 +0,0 @@ -// 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. - -namespace WixToolset.Data -{ - using System; - using System.Diagnostics; - using SimpleJson; - - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class IntermediateSymbol - { - private object tags; - - public IntermediateSymbol(IntermediateSymbolDefinition definition) : this(definition, null, null) - { - } - - public IntermediateSymbol(IntermediateSymbolDefinition definition, SourceLineNumber sourceLineNumber, Identifier id = null) - { - this.Definition = definition; - this.Fields = new IntermediateField[definition.FieldDefinitions.Length]; - this.SourceLineNumbers = sourceLineNumber; - this.Id = id; - } - - public IntermediateSymbolDefinition Definition { get; } - - public IntermediateField[] Fields { get; } - - public SourceLineNumber SourceLineNumbers { get; set; } - - public Identifier Id { get; set; } - - public IntermediateField this[int index] => this.Fields[index]; - - private string DebuggerDisplay => $"{this.Definition?.Name} {this.Id?.Id}"; - - public bool AddTag(string add) - { - if (this.tags == null) - { - this.tags = add; - } - else if (this.tags is string tag) - { - if (tag == add) - { - return false; - } - - this.tags = new[] { tag, add }; - } - else - { - var tagsArray = (string[])this.tags; - var array = new string[tagsArray.Length + 1]; - - for (var i = 0; i < tagsArray.Length; ++i) - { - if (tagsArray[i] == add) - { - return false; - } - - array[i] = tagsArray[i]; - } - - array[tagsArray.Length] = add; - - this.tags = array; - } - - return true; - } - - public bool HasTag(string has) - { - if (this.tags == null) - { - return false; - } - else if (this.tags is string tag) - { - return tag == has; - } - else - { - foreach (var element in (string[])this.tags) - { - if (element == has) - { - return true; - } - } - } - - return false; - } - - public bool RemoveTag(string remove) - { - if (this.tags is string tag) - { - if (tag == remove) - { - this.tags = null; - return true; - } - } - else if (this.tags is string[] tagsArray) - { - if (tagsArray.Length == 2) - { - if (tagsArray[0] == remove) - { - this.tags = tagsArray[1]; - return true; - } - else if (tagsArray[1] == remove) - { - this.tags = tagsArray[0]; - return true; - } - } - else - { - var array = new string[tagsArray.Length - 1]; - var arrayIndex = 0; - var found = false; - - for (var i = 0; i < tagsArray.Length; ++i) - { - if (tagsArray[i] == remove) - { - found = true; - continue; - } - else if (arrayIndex == array.Length) - { - break; - } - - array[arrayIndex++] = tagsArray[i]; - } - - if (found) - { - this.tags = array; - return true; - } - } - } - - return false; - } - - internal static IntermediateSymbol Deserialize(ISymbolDefinitionCreator creator, Uri baseUri, JsonObject jsonObject) - { - var definitionName = jsonObject.GetValueOrDefault("type"); - var idJson = jsonObject.GetValueOrDefault("id"); - var sourceLineNumbersJson = jsonObject.GetValueOrDefault("ln"); - var fieldsJson = jsonObject.GetValueOrDefault("fields"); - var tagsJson = jsonObject.GetValueOrDefault("tags"); - - var id = (idJson == null) ? null : Identifier.Deserialize(idJson); - var sourceLineNumbers = (sourceLineNumbersJson == null) ? null : SourceLineNumber.Deserialize(sourceLineNumbersJson); - - // TODO: this isn't sufficient. - if (!creator.TryGetSymbolDefinitionByName(definitionName, out var definition)) - { - throw new WixException(ErrorMessages.UnknownSymbolType(definitionName)); - } - - var symbol = definition.CreateSymbol(sourceLineNumbers, id); - - for (var i = 0; i < fieldsJson.Count && i < symbol.Fields.Length; ++i) - { - if (fieldsJson[i] is JsonObject fieldJson) - { - symbol.Fields[i] = IntermediateField.Deserialize(symbol.Definition.FieldDefinitions[i], baseUri, fieldJson); - } - } - - if (tagsJson == null || tagsJson.Count == 0) - { - } - else if (tagsJson.Count == 1) - { - symbol.tags = (string)tagsJson[0]; - } - else - { - var tags = new string[tagsJson.Count]; - - for (var i = 0; i < tagsJson.Count; ++i) - { - tags[i] = (string)tagsJson[i]; - } - - symbol.tags = tags; - } - - return symbol; - } - - internal JsonObject Serialize() - { - var jsonObject = new JsonObject - { - { "type", this.Definition.Name } - }; - - var idJson = this.Id?.Serialize(); - if (idJson != null) - { - jsonObject.Add("id", idJson); - } - - var lnJson = this.SourceLineNumbers?.Serialize(); - if (lnJson != null) - { - jsonObject.Add("ln", lnJson); - } - - var fieldsJson = new JsonArray(this.Fields.Length); - - foreach (var field in this.Fields) - { - var fieldJson = field?.Serialize(); - fieldsJson.Add(fieldJson); - } - - jsonObject.Add("fields", fieldsJson); - - if (this.tags is string || this.tags is string[]) - { - JsonArray tagsJson; - - if (this.tags is string tag) - { - tagsJson = new JsonArray(1) { tag }; - } - else - { - var array = (string[])this.tags; - tagsJson = new JsonArray(array.Length); - tagsJson.AddRange(array); - } - - jsonObject.Add("tags", tagsJson); - } - - return jsonObject; - } - } -} diff --git a/src/WixToolset.Data/IntermediateTupleDefinition.cs b/src/WixToolset.Data/IntermediateTupleDefinition.cs deleted file mode 100644 index 102a9f5c..00000000 --- a/src/WixToolset.Data/IntermediateTupleDefinition.cs +++ /dev/null @@ -1,270 +0,0 @@ -// 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. - -namespace WixToolset.Data -{ - using System; - using SimpleJson; - - public class IntermediateSymbolDefinition - { - private object tags; - - public IntermediateSymbolDefinition(string name, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) - : this(SymbolDefinitionType.MustBeFromAnExtension, name, 0, fieldDefinitions, strongSymbolType) - { - } - - public IntermediateSymbolDefinition(string name, int revision, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) - : this(SymbolDefinitionType.MustBeFromAnExtension, name, revision, fieldDefinitions, strongSymbolType) - { - } - - internal IntermediateSymbolDefinition(SymbolDefinitionType type, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) - : this(type, type.ToString(), 0, fieldDefinitions, strongSymbolType) - { - } - - private IntermediateSymbolDefinition(SymbolDefinitionType type, string name, int revision, IntermediateFieldDefinition[] fieldDefinitions, Type strongSymbolType) - { - this.Type = type; - this.Name = name; - this.Revision = revision; - this.FieldDefinitions = fieldDefinitions; - this.StrongSymbolType = strongSymbolType ?? typeof(IntermediateSymbol); -#if DEBUG - if (this.StrongSymbolType != typeof(IntermediateSymbol) && !this.StrongSymbolType.IsSubclassOf(typeof(IntermediateSymbol))) { throw new ArgumentException(nameof(strongSymbolType)); } -#endif - } - - public int Revision { get; } - - public SymbolDefinitionType Type { get; } - - public string Name { get; } - - public IntermediateFieldDefinition[] FieldDefinitions { get; } - - private Type StrongSymbolType { get; } - - public IntermediateSymbol CreateSymbol(SourceLineNumber sourceLineNumber = null, Identifier id = null) - { - var result = (this.StrongSymbolType == typeof(IntermediateSymbol)) ? (IntermediateSymbol)Activator.CreateInstance(this.StrongSymbolType, this) : (IntermediateSymbol)Activator.CreateInstance(this.StrongSymbolType); - result.SourceLineNumbers = sourceLineNumber; - result.Id = id; - - return result; - } - - public bool AddTag(string add) - { - if (this.tags == null) - { - this.tags = add; - } - else if (this.tags is string tag) - { - if (tag == add) - { - return false; - } - - this.tags = new[] { tag, add }; - } - else - { - var tagsArray = (string[])this.tags; - var array = new string[tagsArray.Length + 1]; - - for (var i = 0; i < tagsArray.Length; ++i) - { - if (tagsArray[i] == add) - { - return false; - } - - array[i] = tagsArray[i]; - } - - array[tagsArray.Length] = add; - - this.tags = array; - } - - return true; - } - - public bool HasTag(string has) - { - if (this.tags == null) - { - return false; - } - else if (this.tags is string tag) - { - return tag == has; - } - else - { - foreach (var element in (string[])this.tags) - { - if (element == has) - { - return true; - } - } - } - - return false; - } - - public bool RemoveTag(string remove) - { - if (this.tags is string tag) - { - if (tag == remove) - { - this.tags = null; - return true; - } - } - else if (this.tags is string[] tagsArray) - { - if (tagsArray.Length == 2) - { - if (tagsArray[0] == remove) - { - this.tags = tagsArray[1]; - return true; - } - else if (tagsArray[1] == remove) - { - this.tags = tagsArray[0]; - return true; - } - } - else - { - var array = new string[tagsArray.Length - 1]; - var arrayIndex = 0; - var found = false; - - for (var i = 0; i < tagsArray.Length; ++i) - { - if (tagsArray[i] == remove) - { - found = true; - continue; - } - else if (arrayIndex == array.Length) - { - break; - } - - array[arrayIndex++] = tagsArray[i]; - } - - if (found) - { - this.tags = array; - return true; - } - } - } - - return false; - } - - internal static IntermediateSymbolDefinition Deserialize(JsonObject jsonObject) - { - var name = jsonObject.GetValueOrDefault("name"); - var revision = jsonObject.GetValueOrDefault("rev", 0); - var definitionsJson = jsonObject.GetValueOrDefault("fields"); - var tagsJson = jsonObject.GetValueOrDefault("tags"); - - var fieldDefinitions = new IntermediateFieldDefinition[definitionsJson.Count]; - - for (var i = 0; i < definitionsJson.Count; ++i) - { - var definitionJson = (JsonObject)definitionsJson[i]; - var fieldName = definitionJson.GetValueOrDefault("name"); - var fieldType = definitionJson.GetEnumOrDefault("type", IntermediateFieldType.String); - fieldDefinitions[i] = new IntermediateFieldDefinition(fieldName, fieldType); - } - - var definition = new IntermediateSymbolDefinition(name, revision, fieldDefinitions, null); - - if (tagsJson == null || tagsJson.Count == 0) - { - } - else if (tagsJson.Count == 1) - { - definition.tags = (string)tagsJson[0]; - } - else - { - var tags = new string[tagsJson.Count]; - - for (var i = 0; i < tagsJson.Count; ++i) - { - tags[i] = (string)tagsJson[i]; - } - - definition.tags = tags; - } - - return definition; - } - - internal JsonObject Serialize() - { - var jsonObject = new JsonObject - { - { "name", this.Name } - }; - - if (this.Revision > 0) - { - jsonObject.Add("rev", this.Revision); - } - - var fieldsJson = new JsonArray(this.FieldDefinitions.Length); - - foreach (var fieldDefinition in this.FieldDefinitions) - { - var fieldJson = new JsonObject - { - { "name", fieldDefinition.Name }, - }; - - if (fieldDefinition.Type != IntermediateFieldType.String) - { - fieldJson.Add("type", fieldDefinition.Type.ToString().ToLowerInvariant()); - } - - fieldsJson.Add(fieldJson); - } - - jsonObject.Add("fields", fieldsJson); - - if (this.tags is string || this.tags is string[]) - { - JsonArray tagsJson; - - if (this.tags is string tag) - { - tagsJson = new JsonArray(1) { tag }; - } - else - { - var array = (string[])this.tags; - tagsJson = new JsonArray(array.Length); - tagsJson.AddRange(array); - } - - jsonObject.Add("tags", tagsJson); - } - - return jsonObject; - } - } -} diff --git a/src/WixToolset.Data/IntermediateTupleExtensions.cs b/src/WixToolset.Data/IntermediateTupleExtensions.cs deleted file mode 100644 index 10f0d7f0..00000000 --- a/src/WixToolset.Data/IntermediateTupleExtensions.cs +++ /dev/null @@ -1,121 +0,0 @@ -// 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. - -namespace WixToolset.Data -{ - public static class IntermediateSymbolExtensions - { - public static bool AsBool(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsBool() ?? false; - - public static bool? AsNullableBool(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNullableBool(); - - public static int AsNumber(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNumber() ?? 0; - - public static int? AsNullableNumber(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsNullableNumber(); - - public static string AsString(this IntermediateSymbol symbol, int index) => symbol?.Fields[index].AsString(); - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, bool value) - { - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, bool? value) - { - if (value == null && NoFieldMetadata(symbol, index)) - { - return symbol.Fields[index] = null; - } - - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, long value) - { - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, long? value) - { - if (value == null && NoFieldMetadata(symbol, index)) - { - return symbol.Fields[index] = null; - } - - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, int value) - { - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, int? value) - { - if (value == null && NoFieldMetadata(symbol, index)) - { - return symbol.Fields[index] = null; - } - - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, IntermediateFieldPathValue value) - { - if (value?.Path == null && value?.BaseUri == null && NoFieldMetadata(symbol, index)) - { - return symbol.Fields[index] = null; - } - - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - public static IntermediateField Set(this IntermediateSymbol symbol, int index, string value) - { - if (value == null && NoFieldMetadata(symbol, index)) - { - return symbol.Fields[index] = null; - } - - var definition = symbol.Definition.FieldDefinitions[index]; - - var field = symbol.Fields[index].Set(definition, value); - - return symbol.Fields[index] = field; - } - - private static bool NoFieldMetadata(IntermediateSymbol symbol, int index) - { - var field = symbol?.Fields[index]; - - return field?.Context == null && field?.PreviousValue == null; - } - } -} diff --git a/src/WixToolset.Data/Section.cs b/src/WixToolset.Data/Section.cs deleted file mode 100644 index f9e19f3b..00000000 --- a/src/WixToolset.Data/Section.cs +++ /dev/null @@ -1,242 +0,0 @@ -// 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. - -namespace WixToolset.Data -{ -#if false - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; - using System.Linq; - using System.Xml; - - /// - /// Section in an object file. - /// - public sealed class Section - { - /// - /// Creates a new section as part of an intermediate. - /// - /// Identifier for section. - /// Type of section. - /// Codepage for resulting database. - public Section(string id, SectionType type, int codepage) - { - this.Id = id; - this.Type = type; - this.Codepage = codepage; - - this.Tables = new TableIndexedCollection(); - } - - /// - /// Gets the identifier for the section. - /// - /// Section identifier. - public string Id { get; private set; } - - /// - /// Gets the type of the section. - /// - /// Type of section. - public SectionType Type { get; private set; } - - /// - /// Gets the codepage for the section. - /// - /// Codepage for the section. - public int Codepage { get; private set; } - - /// - /// Gets the tables in the section. - /// - /// Tables in section. - public TableIndexedCollection Tables { get; private set; } - - /// - /// Gets the source line information of the file containing this section. - /// - /// The source line information of the file containing this section. - public SourceLineNumber SourceLineNumbers { get; private set; } - - /// - /// Gets the identity of the intermediate the section is contained within. - /// - public string IntermediateId { get; internal set; } - - /// - /// Gets the identity of the library when the section is contained within one. - /// - public string LibraryId { get; internal set; } - - /// - /// Ensures a table is added to the section's table collection. - /// - /// Table definition for the table. - /// Table in the section. - public Table EnsureTable(TableDefinition tableDefinition) - { - Table table; - if (!this.Tables.TryGetTable(tableDefinition.Name, out table)) - { - table = new Table(this, tableDefinition); - this.Tables.Add(table); - } - - return table; - } - - /// - /// Parse a section from the xml. - /// - /// XmlReader where the intermediate is persisted. - /// TableDefinitions to use in the intermediate. - /// The parsed Section. - internal static Section Read(XmlReader reader, TableDefinitionCollection tableDefinitions) - { - Debug.Assert("section" == reader.LocalName); - - int codepage = 0; - bool empty = reader.IsEmptyElement; - string id = null; - SectionType type = SectionType.Unknown; - - while (reader.MoveToNextAttribute()) - { - switch (reader.Name) - { - case "codepage": - codepage = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture); - break; - case "id": - id = reader.Value; - break; - case "type": - switch (reader.Value) - { - case "bundle": - type = SectionType.Bundle; - break; - case "fragment": - type = SectionType.Fragment; - break; - case "module": - type = SectionType.Module; - break; - case "patchCreation": - type = SectionType.PatchCreation; - break; - case "product": - type = SectionType.Product; - break; - case "patch": - type = SectionType.Patch; - break; - default: - throw new XmlException(); - } - break; - } - } - - if (null == id && (SectionType.Unknown != type && SectionType.Fragment != type)) - { - throw new XmlException(); - } - - if (SectionType.Unknown == type) - { - throw new XmlException(); - } - - Section section = new Section(id, type, codepage); - section.SourceLineNumbers = SourceLineNumber.CreateFromUri(reader.BaseURI); - - List tables = new List
(); - if (!empty) - { - bool done = false; - - while (!done && reader.Read()) - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - switch (reader.LocalName) - { - case "table": - tables.Add(Table.Read(reader, section, tableDefinitions)); - break; - default: - throw new XmlException(); - } - break; - case XmlNodeType.EndElement: - done = true; - break; - } - } - - if (!done) - { - throw new XmlException(); - } - } - - section.Tables = new TableIndexedCollection(tables); - - return section; - } - - /// - /// Persist the Section to an XmlWriter. - /// - /// XmlWriter which reference will be persisted to. - internal void Write(XmlWriter writer) - { - writer.WriteStartElement("section", Intermediate.XmlNamespaceUri); - - if (null != this.Id) - { - writer.WriteAttributeString("id", this.Id); - } - - switch (this.Type) - { - case SectionType.Bundle: - writer.WriteAttributeString("type", "bundle"); - break; - case SectionType.Fragment: - writer.WriteAttributeString("type", "fragment"); - break; - case SectionType.Module: - writer.WriteAttributeString("type", "module"); - break; - case SectionType.Product: - writer.WriteAttributeString("type", "product"); - break; - case SectionType.PatchCreation: - writer.WriteAttributeString("type", "patchCreation"); - break; - case SectionType.Patch: - writer.WriteAttributeString("type", "patch"); - break; - } - - if (0 != this.Codepage) - { - writer.WriteAttributeString("codepage", this.Codepage.ToString()); - } - - // save the rows in table order - foreach (Table table in this.Tables.OrderBy(t => t.Name)) - { - table.Write(writer); - } - - writer.WriteEndElement(); - } - } -#endif -} diff --git a/src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs b/src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs new file mode 100644 index 00000000..e22d53e7 --- /dev/null +++ b/src/WixToolset.Data/SimpleSymbolDefinitionCreator.cs @@ -0,0 +1,31 @@ +// 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. + +namespace WixToolset.Data +{ + using System.Collections.Generic; + + internal class SimpleSymbolDefinitionCreator : ISymbolDefinitionCreator + { + private Dictionary CustomDefinitionByName { get; } = new Dictionary(); + + public void AddCustomSymbolDefinition(IntermediateSymbolDefinition definition) + { + if (!this.CustomDefinitionByName.TryGetValue(definition.Name, out var existing) || definition.Revision > existing.Revision) + { + this.CustomDefinitionByName[definition.Name] = definition; + } + } + + public bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = SymbolDefinitions.ByName(name); + + if (symbolDefinition == null) + { + symbolDefinition = this.CustomDefinitionByName.GetValueOrDefault(name); + } + + return symbolDefinition != null; + } + } +} diff --git a/src/WixToolset.Data/SimpleTupleDefinitionCreator.cs b/src/WixToolset.Data/SimpleTupleDefinitionCreator.cs deleted file mode 100644 index e22d53e7..00000000 --- a/src/WixToolset.Data/SimpleTupleDefinitionCreator.cs +++ /dev/null @@ -1,31 +0,0 @@ -// 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. - -namespace WixToolset.Data -{ - using System.Collections.Generic; - - internal class SimpleSymbolDefinitionCreator : ISymbolDefinitionCreator - { - private Dictionary CustomDefinitionByName { get; } = new Dictionary(); - - public void AddCustomSymbolDefinition(IntermediateSymbolDefinition definition) - { - if (!this.CustomDefinitionByName.TryGetValue(definition.Name, out var existing) || definition.Revision > existing.Revision) - { - this.CustomDefinitionByName[definition.Name] = definition; - } - } - - public bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) - { - symbolDefinition = SymbolDefinitions.ByName(name); - - if (symbolDefinition == null) - { - symbolDefinition = this.CustomDefinitionByName.GetValueOrDefault(name); - } - - return symbolDefinition != null; - } - } -} diff --git a/src/WixToolset.Data/SymbolWithSection.cs b/src/WixToolset.Data/SymbolWithSection.cs new file mode 100644 index 00000000..89a5fccd --- /dev/null +++ b/src/WixToolset.Data/SymbolWithSection.cs @@ -0,0 +1,90 @@ +// 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. + +namespace WixToolset.Data +{ + using System; + using System.Collections.Generic; + using System.Linq; + + /// + /// Symbol with section representing a single unique symbol. + /// + public sealed class SymbolWithSection + { + private HashSet possibleConflicts; + private HashSet redundants; + + /// + /// Creates a symbol for a symbol. + /// + /// Symbol for the symbol + public SymbolWithSection(IntermediateSection section, IntermediateSymbol symbol) + { + this.Symbol = symbol; + this.Section = section; + this.Name = String.Concat(this.Symbol.Definition.Name, ":", this.Symbol.Id.Id); + } + + /// + /// Gets the accessibility of the symbol which is a direct reflection of the accessibility of the row's accessibility. + /// + /// Accessbility of the symbol. + public AccessModifier Access => this.Symbol.Id.Access; + + /// + /// Gets the name of the symbol. + /// + /// Name of the symbol. + public string Name { get; } + + /// + /// Gets the symbol for this symbol. + /// + /// Symbol for this symbol. + public IntermediateSymbol Symbol { get; } + + /// + /// Gets the section for the symbol. + /// + /// Section for the symbol. + public IntermediateSection Section { get; } + + /// + /// Gets any duplicates of this symbol with sections that are possible conflicts. + /// + public IEnumerable PossiblyConflicts => this.possibleConflicts ?? Enumerable.Empty(); + + /// + /// Gets any duplicates of this symbol with sections that are redundant. + /// + public IEnumerable Redundants => this.redundants ?? Enumerable.Empty(); + + /// + /// Adds a duplicate symbol with sections that is a possible conflict. + /// + /// Symbol with section that is a possible conflict of this symbol. + public void AddPossibleConflict(SymbolWithSection symbolWithSection) + { + if (null == this.possibleConflicts) + { + this.possibleConflicts = new HashSet(); + } + + this.possibleConflicts.Add(symbolWithSection); + } + + /// + /// Adds a duplicate symbol that is redundant. + /// + /// Symbol with section that is redundant of this symbol. + public void AddRedundant(SymbolWithSection symbolWithSection) + { + if (null == this.redundants) + { + this.redundants = new HashSet(); + } + + this.redundants.Add(symbolWithSection); + } + } +} diff --git a/src/WixToolset.Data/TupleWithSection.cs b/src/WixToolset.Data/TupleWithSection.cs deleted file mode 100644 index 89a5fccd..00000000 --- a/src/WixToolset.Data/TupleWithSection.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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. - -namespace WixToolset.Data -{ - using System; - using System.Collections.Generic; - using System.Linq; - - /// - /// Symbol with section representing a single unique symbol. - /// - public sealed class SymbolWithSection - { - private HashSet possibleConflicts; - private HashSet redundants; - - /// - /// Creates a symbol for a symbol. - /// - /// Symbol for the symbol - public SymbolWithSection(IntermediateSection section, IntermediateSymbol symbol) - { - this.Symbol = symbol; - this.Section = section; - this.Name = String.Concat(this.Symbol.Definition.Name, ":", this.Symbol.Id.Id); - } - - /// - /// Gets the accessibility of the symbol which is a direct reflection of the accessibility of the row's accessibility. - /// - /// Accessbility of the symbol. - public AccessModifier Access => this.Symbol.Id.Access; - - /// - /// Gets the name of the symbol. - /// - /// Name of the symbol. - public string Name { get; } - - /// - /// Gets the symbol for this symbol. - /// - /// Symbol for this symbol. - public IntermediateSymbol Symbol { get; } - - /// - /// Gets the section for the symbol. - /// - /// Section for the symbol. - public IntermediateSection Section { get; } - - /// - /// Gets any duplicates of this symbol with sections that are possible conflicts. - /// - public IEnumerable PossiblyConflicts => this.possibleConflicts ?? Enumerable.Empty(); - - /// - /// Gets any duplicates of this symbol with sections that are redundant. - /// - public IEnumerable Redundants => this.redundants ?? Enumerable.Empty(); - - /// - /// Adds a duplicate symbol with sections that is a possible conflict. - /// - /// Symbol with section that is a possible conflict of this symbol. - public void AddPossibleConflict(SymbolWithSection symbolWithSection) - { - if (null == this.possibleConflicts) - { - this.possibleConflicts = new HashSet(); - } - - this.possibleConflicts.Add(symbolWithSection); - } - - /// - /// Adds a duplicate symbol that is redundant. - /// - /// Symbol with section that is redundant of this symbol. - public void AddRedundant(SymbolWithSection symbolWithSection) - { - if (null == this.redundants) - { - this.redundants = new HashSet(); - } - - this.redundants.Add(symbolWithSection); - } - } -} -- cgit v1.2.3-55-g6feb