From 6d8b6f79b44b6a41a630aa3aad5a3c7f16701798 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 11 Apr 2020 21:49:09 +1000 Subject: General cleanup. Try not to send strings to specify the tuple or table. Try to avoid using the Set method on tuples. Always create new tuples and add them to the section in the same line. --- src/WixToolset.Core/CompilerCore.cs | 62 +++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'src/WixToolset.Core/CompilerCore.cs') diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs index 51828975..93f9276c 100644 --- a/src/WixToolset.Core/CompilerCore.cs +++ b/src/WixToolset.Core/CompilerCore.cs @@ -14,6 +14,7 @@ namespace WixToolset.Core using System.Xml.Linq; using WixToolset.Data; using WixToolset.Data.Tuples; + using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; @@ -166,9 +167,10 @@ namespace WixToolset.Core /// Add a tuple to the active section. /// /// Tuple to add. - public void AddTuple(IntermediateTuple tuple) + public T AddTuple(T tuple) + where T : IntermediateTuple { - this.ActiveSection.Tuples.Add(tuple); + return this.ActiveSection.AddTuple(tuple); } /// @@ -350,23 +352,6 @@ namespace WixToolset.Core return this.parseHelper.CreateGuid(namespaceGuid, value); } - /// - /// Creates a tuple in the active section. - /// - /// Source and line number of current row. - /// Type of tuple to create. - /// Optional identifier. - /// New tuple. - public IntermediateTuple CreateTuple(SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, Identifier identifier = null) - { - var tupleDefinition = TupleDefinitions.ByType(tupleType); - var tuple = tupleDefinition.CreateTuple(sourceLineNumbers, identifier); - - this.ActiveSection.Tuples.Add(tuple); - - return tuple; - } - /// /// Creates directories using the inline directory syntax. /// @@ -394,26 +379,37 @@ namespace WixToolset.Core } /// - /// Create a WixSimpleReference row in the active section. + /// Create a WixSimpleReferenceTuple in the active section. /// /// Source line information for the row. - /// The table name of the simple reference. + /// The tuple name of the simple reference. /// The primary keys of the simple reference. - public void CreateSimpleReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys) + public void CreateSimpleReference(SourceLineNumber sourceLineNumbers, string tupleName, params string[] primaryKeys) { if (!this.EncounteredError) { - string joinedKeys = String.Join("/", primaryKeys); - string id = String.Concat(tableName, ":", joinedKeys); + var joinedKeys = String.Join("/", primaryKeys); + var id = String.Concat(tupleName, ":", joinedKeys); // If this simple reference hasn't been added to the active section already, add it. if (this.activeSectionSimpleReferences.Add(id)) { - this.parseHelper.CreateSimpleReference(this.ActiveSection, sourceLineNumbers, tableName, primaryKeys); + this.parseHelper.CreateSimpleReference(this.ActiveSection, sourceLineNumbers, tupleName, primaryKeys); } } } + /// + /// Create a WixSimpleReferenceTuple in the active section. + /// + /// Source line information for the row. + /// The tuple definition of the simple reference. + /// The primary keys of the simple reference. + public void CreateSimpleReference(SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, params string[] primaryKeys) + { + this.CreateSimpleReference(sourceLineNumbers, tupleDefinition.Name, primaryKeys); + } + /// /// A row in the WixGroup table is added for this child node and its parent node. /// @@ -431,7 +427,7 @@ namespace WixToolset.Core } /// - /// Add the appropriate rows to make sure that the given table shows up + /// Add the appropriate tuples to make sure that the given table shows up /// in the resulting output. /// /// Source line numbers. @@ -444,6 +440,20 @@ namespace WixToolset.Core } } + /// + /// Add the appropriate tuples to make sure that the given table shows up + /// in the resulting output. + /// + /// Source line numbers. + /// Definition of the table to ensure existance of. + public void EnsureTable(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition) + { + if (!this.EncounteredError) + { + this.parseHelper.EnsureTable(this.ActiveSection, sourceLineNumbers, tableDefinition); + } + } + /// /// Get an attribute value. /// -- cgit v1.2.3-55-g6feb