From 404f34f00ecce034a8a06fe4757789c6ce62f3f6 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 14 Nov 2017 23:08:24 -0800 Subject: Remove ICompilerCore, introduce IParseHelper and other small fixes --- .../BaseCompilerExtension.cs | 76 +++++ src/WixToolset.Extensibility/CompilerConstants.cs | 2 +- src/WixToolset.Extensibility/CompilerExtension.cs | 75 ----- src/WixToolset.Extensibility/ComponentKeyPath.cs | 2 - src/WixToolset.Extensibility/IBinderCore.cs | 35 --- src/WixToolset.Extensibility/ICompileContext.cs | 4 + src/WixToolset.Extensibility/ICompilerCore.cs | 339 --------------------- src/WixToolset.Extensibility/ICompilerExtension.cs | 14 +- .../Services/IParseHelper.cs | 334 ++++++++++++++++++++ 9 files changed, 418 insertions(+), 463 deletions(-) create mode 100644 src/WixToolset.Extensibility/BaseCompilerExtension.cs delete mode 100644 src/WixToolset.Extensibility/CompilerExtension.cs delete mode 100644 src/WixToolset.Extensibility/IBinderCore.cs delete mode 100644 src/WixToolset.Extensibility/ICompilerCore.cs create mode 100644 src/WixToolset.Extensibility/Services/IParseHelper.cs (limited to 'src') diff --git a/src/WixToolset.Extensibility/BaseCompilerExtension.cs b/src/WixToolset.Extensibility/BaseCompilerExtension.cs new file mode 100644 index 00000000..508886d3 --- /dev/null +++ b/src/WixToolset.Extensibility/BaseCompilerExtension.cs @@ -0,0 +1,76 @@ +// 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.Extensibility +{ + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a compiler extension. + /// + public abstract class BaseCompilerExtension : ICompilerExtension + { + /// + /// ParserHelper for use by the extension. + /// + protected IParseHelper ParseHelper { get; private set; } + + /// + /// Gets the schema namespace for this extension. + /// + /// Schema namespace supported by this extension. + public XNamespace Namespace { get; protected set; } + + /// + /// Called at the beginning of the compilation of a source file. + /// + public virtual void PreCompile(ICompileContext context) + { + this.ParseHelper = context.ServiceProvider.GetService(); + } + + /// + /// Processes an attribute for the Compiler. + /// + /// Parent element of attribute. + /// Attribute to process. + /// Extra information about the context in which this element is being parsed. + public virtual void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context) + { + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); + } + + /// + /// Processes an element for the Compiler. + /// + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public virtual void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + this.ParseHelper.UnexpectedElement(parentElement, element); + } + + /// + /// Processes an element for the Compiler, with the ability to supply a component keypath. + /// + /// Parent element of element to process. + /// Element to process. + /// Explicit key path. + /// Extra information about the context in which this element is being parsed. + public virtual ComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + this.ParseElement(intermediate, section, parentElement, element, context); + return null; + } + + /// + /// Called at the end of the compilation of a source file. + /// + public virtual void PostCompile(Intermediate intermediate) + { + } + } +} diff --git a/src/WixToolset.Extensibility/CompilerConstants.cs b/src/WixToolset.Extensibility/CompilerConstants.cs index 6d4ca742..9f666b43 100644 --- a/src/WixToolset.Extensibility/CompilerConstants.cs +++ b/src/WixToolset.Extensibility/CompilerConstants.cs @@ -1,6 +1,6 @@ // 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 +namespace WixToolset.Extensibility { using System; diff --git a/src/WixToolset.Extensibility/CompilerExtension.cs b/src/WixToolset.Extensibility/CompilerExtension.cs deleted file mode 100644 index d0bb4a10..00000000 --- a/src/WixToolset.Extensibility/CompilerExtension.cs +++ /dev/null @@ -1,75 +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.Extensibility -{ - using System.Collections.Generic; - using System.Xml.Linq; - using WixToolset.Data; - - /// - /// Base class for creating a compiler extension. - /// - public abstract class CompilerExtension : ICompilerExtension - { - /// - /// Gets or sets the compiler core for the extension. - /// - /// Compiler core for the extension. - public ICompilerCore Core { get; set; } - - /// - /// Gets the schema namespace for this extension. - /// - /// Schema namespace supported by this extension. - public XNamespace Namespace { get; protected set; } - - /// - /// Called at the beginning of the compilation of a source file. - /// - public virtual void PreCompile(ICompileContext context) - { - } - - /// - /// Processes an attribute for the Compiler. - /// - /// Parent element of attribute. - /// Attribute to process. - /// Extra information about the context in which this element is being parsed. - public virtual void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary context) - { - this.Core.UnexpectedAttribute(parentElement, attribute); - } - - /// - /// Processes an element for the Compiler. - /// - /// Parent element of element to process. - /// Element to process. - /// Extra information about the context in which this element is being parsed. - public virtual void ParseElement(XElement parentElement, XElement element, IDictionary context) - { - this.Core.UnexpectedElement(parentElement, element); - } - - /// - /// Processes an element for the Compiler, with the ability to supply a component keypath. - /// - /// Parent element of element to process. - /// Element to process. - /// Explicit key path. - /// Extra information about the context in which this element is being parsed. - public virtual ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary context) - { - this.ParseElement(parentElement, element, context); - return null; - } - - /// - /// Called at the end of the compilation of a source file. - /// - public virtual void PostCompile(Intermediate intermediate) - { - } - } -} diff --git a/src/WixToolset.Extensibility/ComponentKeyPath.cs b/src/WixToolset.Extensibility/ComponentKeyPath.cs index f00e8f74..15cbb02f 100644 --- a/src/WixToolset.Extensibility/ComponentKeyPath.cs +++ b/src/WixToolset.Extensibility/ComponentKeyPath.cs @@ -2,8 +2,6 @@ namespace WixToolset.Extensibility { - using System; - public enum ComponentKeyPathType { /// diff --git a/src/WixToolset.Extensibility/IBinderCore.cs b/src/WixToolset.Extensibility/IBinderCore.cs deleted file mode 100644 index dd3fa3fe..00000000 --- a/src/WixToolset.Extensibility/IBinderCore.cs +++ /dev/null @@ -1,35 +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.Extensibility -{ - using WixToolset.Data; - - public interface IBinderCore : IMessageHandler - { - /// - /// Gets or sets the file manager core for the extension. - /// - /// File manager core for the extension. - IBinderFileManagerCore FileManagerCore { get; set; } - - /// - /// Gets whether the binder core encountered an error while processing. - /// - /// Flag if core encountered an error during processing. - bool EncounteredError { get; } - - /// - /// Gets the table definitions used by the Binder. - /// - /// Table definitions used by the binder. - //TableDefinitionCollection TableDefinitions { get; } - - /// - /// Generate an identifier by hashing data from the row. - /// - /// Three letter or less prefix for generated row identifier. - /// Information to hash. - /// The generated identifier. - string CreateIdentifier(string prefix, params string[] args); - } -} diff --git a/src/WixToolset.Extensibility/ICompileContext.cs b/src/WixToolset.Extensibility/ICompileContext.cs index d48e9539..bd0d0a4b 100644 --- a/src/WixToolset.Extensibility/ICompileContext.cs +++ b/src/WixToolset.Extensibility/ICompileContext.cs @@ -19,6 +19,10 @@ namespace WixToolset.Extensibility string OutputPath { get; set; } + /// + /// Gets or sets the platform which the compiler will use when defaulting 64-bit attributes and elements. + /// + /// The platform which the compiler will use when defaulting 64-bit attributes and elements. Platform Platform { get; set; } XDocument Source { get; set; } diff --git a/src/WixToolset.Extensibility/ICompilerCore.cs b/src/WixToolset.Extensibility/ICompilerCore.cs deleted file mode 100644 index d71f9cbe..00000000 --- a/src/WixToolset.Extensibility/ICompilerCore.cs +++ /dev/null @@ -1,339 +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.Extensibility -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Xml.Linq; - using WixToolset.Data; - - /// - /// Core interface provided by the compiler. - /// - public interface ICompilerCore : IMessageHandler - { - /// - /// Gets whether the compiler core encountered an error while processing. - /// - /// Flag if core encountered an error during processing. - bool EncounteredError { get; } - - /// - /// Gets the platform which the compiler will use when defaulting 64-bit attributes and elements. - /// - /// The platform which the compiler will use when defaulting 64-bit attributes and elements. - Platform CurrentPlatform { get; } - - /// - /// Creates a version 3 name-based UUID. - /// - /// The namespace UUID. - /// The value. - /// The generated GUID for the given namespace and value. - string CreateGuid(Guid namespaceGuid, string value); - - /// - /// Create an identifier by hashing data from the row. - /// - /// Three letter or less prefix for generated row identifier. - /// Information to hash. - /// The new identifier. - Identifier CreateIdentifier(string prefix, params string[] args); - - /// - /// Create an identifier based on passed file name - /// - /// File name to generate identifer from - /// - Identifier CreateIdentifierFromFilename(string filename); - - /// - /// Convert a bit array into an int value. - /// - /// The bit array to convert. - /// The converted int value. - int CreateIntegerFromBitArray(BitArray bits); - - /// - /// Creates a row in the active section. - /// - /// Source and line number of current row. - /// Name of table to create row in. - /// Optional identifier for the row. - /// New row. - IntermediateTuple CreateRow(SourceLineNumber sourceLineNumbers, string tableName, Identifier identifier = null); - - /// - /// Creates directories using the inline directory syntax. - /// - /// Source line information. - /// The attribute to parse. - /// Optional identifier of parent directory. - /// Identifier of the leaf directory created. - string CreateDirectoryReferenceFromInlineSyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId); - - /// - /// Creates a Registry row in the active section. - /// - /// Source and line number of the current row. - /// The registry entry root. - /// The registry entry key. - /// The registry entry name. - /// The registry entry value. - /// The component which will control installation/uninstallation of the registry entry. - /// If true, "escape" leading '#' characters so the value is written as a REG_SZ. - Identifier CreateRegistryRow(SourceLineNumber sourceLineNumbers, int root, string key, string name, string value, string componentId, bool escapeLeadingHash = false); - - /// - /// Creates a short file/directory name using an identifier and long file/directory name as input. - /// - /// The long file/directory name. - /// The option to keep the extension on generated short names. - /// true if wildcards are allowed in the filename. - /// Any additional information to include in the hash for the generated short name. - /// The generated 8.3-compliant short file/directory name. - string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args); - - /// - /// Create a WixSimpleReference row in the active section. - /// - /// Source line information for the row. - /// The table name of the simple reference. - /// The primary keys of the simple reference. - void CreateSimpleReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys); - - /// - /// Creates WixComplexReference and WixGroup rows in the active section. - /// - /// Source line information. - /// The parent type. - /// The parent id. - /// The parent language. - /// The child type. - /// The child id. - /// Whether the child is primary. - void CreateComplexReference(SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary); - - /// - /// Creates a patch resource reference to the list of resoures to be filtered when producing a patch. This method should only be used when processing children of a patch family. - /// - /// Source and line number of current row. - /// Name of table to create row in. - /// Array of keys that make up the primary key of the table. - /// New row. - void CreatePatchFamilyChildReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys); - - /// - /// Checks if the string contains a property (i.e. "foo[Property]bar") - /// - /// String to evaluate for properties. - /// True if a property is found in the string. - bool ContainsProperty(string possibleProperty); - - /// - /// Add the appropriate rows to make sure that the given table shows up in the resulting output. - /// - /// Source line numbers. - /// Name of the table to ensure existance of. - void EnsureTable(SourceLineNumber sourceLineNumbers, string tableName); - - /// - /// Get an attribute value and displays an error if the value is empty by default. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// A rule for the contents of the value. If the contents do not follow the rule, an error is thrown. - /// The attribute's value. - string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule = EmptyRule.CanBeWhitespaceOnly); - - /// - /// Gets a Bundle variable value and displays an error for an illegal value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The attribute's value. - string GetAttributeBundleVariableValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); - - /// - /// Get a guid attribute value and displays an error for an illegal guid value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// Determines whether the guid can be automatically generated. - /// If true, no error is raised on empty value. If false, an error is raised. - /// The attribute's guid value or a special value if an error occurred. - string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false); - - /// - /// Get an identifier attribute value and displays an error for an illegal identifier value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The attribute's identifier value or a special value if an error occurred. - Identifier GetAttributeIdentifier(SourceLineNumber sourceLineNumbers, XAttribute attribute); - - /// - /// Get an identifier attribute value and displays an error for an illegal identifier value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The attribute's identifier value or a special value if an error occurred. - string GetAttributeIdentifierValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); - - /// - /// Get an integer attribute value and displays an error for an illegal integer value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The minimum legal value. - /// The maximum legal value. - /// The attribute's integer value or a special value if an error occurred during conversion. - int GetAttributeIntegerValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, int minimum, int maximum); - - /// - /// Get a long integral attribute value and displays an error for an illegal long value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The minimum legal value. - /// The maximum legal value. - /// The attribute's long value or a special value if an error occurred during conversion. - long GetAttributeLongValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, long minimum, long maximum); - - /// - /// Gets a long filename value and displays an error for an illegal long filename value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// true if wildcards are allowed in the filename. - /// true if relative paths are allowed in the filename. - /// The attribute's long filename value. - string GetAttributeLongFilename(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowWildcards = false, bool allowRelative = false); - - /// - /// Gets a RegistryRoot as a MsiInterop.MsidbRegistryRoot value and displays an error for an illegal value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// Whether HKMU is returned as -1 (true), or treated as an error (false). - /// The attribute's RegisitryRootType value. - int GetAttributeMsidbRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu); - - /// - /// Gets a version value or possibly a binder variable and displays an error for an illegal version value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The attribute's version value. - string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); - - /// - /// Gets a yes/no value and displays an error for an illegal yes/no value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The attribute's YesNoType value. - YesNoType GetAttributeYesNoValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); - - /// - /// Gets a yes/no/default value and displays an error for an illegal yes/no/default value. - /// - /// Source line information about the owner element. - /// The attribute containing the value to get. - /// The attribute's YesNoType value. - YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); - - /// - /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace. - /// - /// The node to ensure inner text is a condition. - /// The value converted into a safe condition. - string GetConditionInnerText(XElement node); - - /// - /// Get an element's inner text and trims any extra whitespace. - /// - /// The element with inner text to be trimmed. - /// The node's inner text trimmed. - string GetTrimmedInnerText(XElement element); - - /// - /// Verifies that a value is a legal identifier. - /// - /// The value to verify. - /// true if the value is an identifier; false otherwise. - bool IsValidIdentifier(string value); - - /// - /// Verifies if an identifier is a valid loc identifier. - /// - /// Identifier to verify. - /// True if the identifier is a valid loc identifier. - bool IsValidLocIdentifier(string identifier); - - /// - /// Verifies if a filename is a valid long filename. - /// - /// Filename to verify. - /// true if wildcards are allowed in the filename. - /// true if relative paths are allowed in the filename. - /// True if the filename is a valid long filename - bool IsValidLongFilename(string filename, bool allowWildcards = false, bool allowRelative = false); - - /// - /// Verifies if a filename is a valid short filename. - /// - /// Filename to verify. - /// true if wildcards are allowed in the filename. - /// True if the filename is a valid short filename - bool IsValidShortFilename(string filename, bool allowWildcards = false); - - /// - /// Attempts to use an extension to parse the attribute. - /// - /// Element containing attribute to be parsed. - /// Attribute to be parsed. - /// Extra information about the context in which this element is being parsed. - void ParseExtensionAttribute(XElement element, XAttribute attribute, IDictionary context = null); - - /// - /// Attempts to use an extension to parse the element. - /// - /// Element containing element to be parsed. - /// Element to be parsed. - /// Extra information about the context in which this element is being parsed. - void ParseExtensionElement(XElement parentElement, XElement element, IDictionary context = null); - - /// - /// Process all children of the element looking for extensions and erroring on the unexpected. - /// - /// Element to parse children. - void ParseForExtensionElements(XElement element); - - /// - /// Sets a bit in a bit array based on the index at which an attribute name was found in a string array. - /// - /// Array of attributes that map to bits. - /// Name of attribute to check. - /// Value of attribute to check. - /// The bit array in which the bit will be set if found. - /// The offset into the bit array. - /// true if the bit was set; false otherwise. - bool TrySetBitFromName(string[] attributeNames, string attributeName, YesNoType attributeValue, BitArray bits, int offset); - - /// - /// Called when the compiler encounters an unexpected attribute. - /// - /// Parent element that found unexpected attribute. - /// Unexpected attribute. - void UnexpectedAttribute(XElement element, XAttribute attribute); - - /// - /// Called when the compiler encounters an unexpected child element. - /// - /// Parent element that found unexpected child. - /// Unexpected child element. - void UnexpectedElement(XElement parentElement, XElement childElement); - } -} diff --git a/src/WixToolset.Extensibility/ICompilerExtension.cs b/src/WixToolset.Extensibility/ICompilerExtension.cs index 1746a571..0aa5c9e2 100644 --- a/src/WixToolset.Extensibility/ICompilerExtension.cs +++ b/src/WixToolset.Extensibility/ICompilerExtension.cs @@ -5,20 +5,12 @@ namespace WixToolset.Extensibility using System.Collections.Generic; using System.Xml.Linq; using WixToolset.Data; - using WixToolset.Extensibility.Services; /// /// Interface all compiler extensions implement. /// public interface ICompilerExtension { -#if false - /// - /// Gets or sets the compiler core for the extension. - /// - /// Compiler core for the extension. - ICompilerCore Core { get; set; } -#endif /// /// Gets the schema namespace for this extension. /// @@ -36,7 +28,7 @@ namespace WixToolset.Extensibility /// Parent element of attribute. /// Attribute to process. /// Extra information about the context in which this element is being parsed. - void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary context); + void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context); /// /// Processes an element for the Compiler. @@ -44,7 +36,7 @@ namespace WixToolset.Extensibility /// Parent element of element to process. /// Element to process. /// Extra information about the context in which this element is being parsed. - void ParseElement(XElement parentElement, XElement element, IDictionary context); + void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context); /// /// Processes an element for the Compiler, with the ability to supply a component keypath. @@ -52,7 +44,7 @@ namespace WixToolset.Extensibility /// Parent element of element to process. /// Element to process. /// Extra information about the context in which this element is being parsed. - ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary context); + ComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context); /// /// Called at the end of the compilation of a source file. diff --git a/src/WixToolset.Extensibility/Services/IParseHelper.cs b/src/WixToolset.Extensibility/Services/IParseHelper.cs new file mode 100644 index 00000000..46ade2e1 --- /dev/null +++ b/src/WixToolset.Extensibility/Services/IParseHelper.cs @@ -0,0 +1,334 @@ +// 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.Extensibility.Services +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + + /// + /// Core interface provided by the compiler. + /// + public interface IParseHelper + { + /// + /// Creates a version 3 name-based UUID. + /// + /// The namespace UUID. + /// The value. + /// The generated GUID for the given namespace and value. + string CreateGuid(Guid namespaceGuid, string value); + + /// + /// Create an identifier by hashing data from the row. + /// + /// Three letter or less prefix for generated row identifier. + /// Information to hash. + /// The new identifier. + Identifier CreateIdentifier(string prefix, params string[] args); + + /// + /// Create an identifier based on passed file name + /// + /// File name to generate identifer from + /// + Identifier CreateIdentifierFromFilename(string filename); + + /// + /// Creates a row in the section. + /// + /// Section to add the new tuple to. + /// Source and line number of current row. + /// Name of table to create row in. + /// Optional identifier for the row. + /// New row. + IntermediateTuple CreateRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName, Identifier identifier = null); + + /// + /// Creates a row in the section. + /// + /// Section to add the new tuple to. + /// Source and line number of current row. + /// Type of tuple to create. + /// Optional identifier for the row. + /// New row. + IntermediateTuple CreateRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, Identifier identifier = null); + + /// + /// Creates a directory row from a name. + /// + /// Section to add the new tuple to. + /// Source line information. + /// Optional identifier for the new row. + /// Optional identifier for the parent row. + /// Long name of the directory. + /// Optional short name of the directory. + /// Optional source name for the directory. + /// Optional short source name for the directory. + /// Identifier for the newly created row. + Identifier CreateDirectoryRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null, ISet sectionInlinedDirectoryIds = null); + + /// + /// Creates directories using the inline directory syntax. + /// + /// Source line information. + /// The attribute to parse. + /// Optional identifier of parent directory. + /// Identifier of the leaf directory created. + string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId); + + /// + /// Creates a Registry row in the active section. + /// + /// Source and line number of the current row. + /// The registry entry root. + /// The registry entry key. + /// The registry entry name. + /// The registry entry value. + /// The component which will control installation/uninstallation of the registry entry. + /// If true, "escape" leading '#' characters so the value is written as a REG_SZ. + Identifier CreateRegistryRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, int root, string key, string name, string value, string componentId, bool escapeLeadingHash); + + /// + /// Creates a short file/directory name using an identifier and long file/directory name as input. + /// + /// The long file/directory name. + /// The option to keep the extension on generated short names. + /// true if wildcards are allowed in the filename. + /// Any additional information to include in the hash for the generated short name. + /// The generated 8.3-compliant short file/directory name. + string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args); + + /// + /// Create a WixSimpleReference row in the active section. + /// + /// Source line information for the row. + /// The table name of the simple reference. + /// The primary keys of the simple reference. + void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys); + + /// + /// Creates WixComplexReference and WixGroup rows in the active section. + /// + /// Source line information. + /// The parent type. + /// The parent id. + /// The parent language. + /// The child type. + /// The child id. + /// Whether the child is primary. + void CreateComplexReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary); + + /// + /// A row in the WixGroup table is added for this child node and its parent node. + /// + /// Source line information for the row. + /// Type of child's complex reference parent. + /// Id of the parenet node. + /// Complex reference type of child + /// Id of the Child Node. + void CreateWixGroupRow(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType childType, string childId); + + /// + /// Checks if the string contains a property (i.e. "foo[Property]bar") + /// + /// String to evaluate for properties. + /// True if a property is found in the string. + bool ContainsProperty(string possibleProperty); + + /// + /// Add the appropriate rows to make sure that the given table shows up in the resulting output. + /// + /// Source line numbers. + /// Name of the table to ensure existance of. + void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName); + + /// + /// Get an attribute value and displays an error if the value is empty by default. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// A rule for the contents of the value. If the contents do not follow the rule, an error is thrown. + /// The attribute's value. + string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule = EmptyRule.CanBeWhitespaceOnly); + + /// + /// Get a guid attribute value and displays an error for an illegal guid value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// Determines whether the guid can be automatically generated. + /// If true, no error is raised on empty value. If false, an error is raised. + /// The attribute's guid value or a special value if an error occurred. + string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false); + + /// + /// Get an identifier attribute value and displays an error for an illegal identifier value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's identifier value or a special value if an error occurred. + Identifier GetAttributeIdentifier(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Get an identifier attribute value and displays an error for an illegal identifier value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's identifier value or a special value if an error occurred. + string GetAttributeIdentifierValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Gets the attribute value as inline directory syntax. + /// + /// Source line information. + /// Attribute containing the value to get. + /// Flag indicates whether the inline directory syntax should be processed to create a directory row or to create a directory reference. + /// Inline directory syntax split into array of strings or null if the syntax did not parse. + string[] GetAttributeInlineDirectorySyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool resultUsedToCreateReference); + + /// + /// Get an integer attribute value and displays an error for an illegal integer value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The minimum legal value. + /// The maximum legal value. + /// The attribute's integer value or a special value if an error occurred during conversion. + int GetAttributeIntegerValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, int minimum, int maximum); + + /// + /// Get a long integral attribute value and displays an error for an illegal long value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The minimum legal value. + /// The maximum legal value. + /// The attribute's long value or a special value if an error occurred during conversion. + long GetAttributeLongValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, long minimum, long maximum); + + /// + /// Gets a long filename value and displays an error for an illegal long filename value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// true if wildcards are allowed in the filename. + /// true if relative paths are allowed in the filename. + /// The attribute's long filename value. + string GetAttributeLongFilename(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowWildcards = false, bool allowRelative = false); + + /// + /// Gets a version value or possibly a binder variable and displays an error for an illegal version value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's version value. + string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Gets a yes/no value and displays an error for an illegal yes/no value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's YesNoType value. + YesNoType GetAttributeYesNoValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Gets a yes/no/default value and displays an error for an illegal yes/no/default value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's YesNoType value. + YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace. + /// + /// The node to ensure inner text is a condition. + /// The value converted into a safe condition. + string GetConditionInnerText(XElement node); + + /// + /// Get an element's inner text and trims any extra whitespace. + /// + /// The element with inner text to be trimmed. + /// The node's inner text trimmed. + string GetTrimmedInnerText(XElement element); + + /// + /// Verifies that a value is a legal identifier. + /// + /// The value to verify. + /// true if the value is an identifier; false otherwise. + bool IsValidIdentifier(string value); + + /// + /// Verifies if an identifier is a valid loc identifier. + /// + /// Identifier to verify. + /// True if the identifier is a valid loc identifier. + bool IsValidLocIdentifier(string identifier); + + /// + /// Verifies if a filename is a valid long filename. + /// + /// Filename to verify. + /// true if wildcards are allowed in the filename. + /// true if relative paths are allowed in the filename. + /// True if the filename is a valid long filename + bool IsValidLongFilename(string filename, bool allowWildcards = false, bool allowRelative = false); + + /// + /// Verifies if a filename is a valid short filename. + /// + /// Filename to verify. + /// true if wildcards are allowed in the filename. + /// True if the filename is a valid short filename + bool IsValidShortFilename(string filename, bool allowWildcards = false); + + /// + /// Attempts to use an extension to parse the attribute. + /// + /// Element containing attribute to be parsed. + /// Attribute to be parsed. + /// Extra information about the context in which this element is being parsed. + void ParseExtensionAttribute(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement element, XAttribute attribute, IDictionary context = null); + + /// + /// Attempts to use an extension to parse the element. + /// + /// Element containing element to be parsed. + /// Element to be parsed. + /// Extra information about the context in which this element is being parsed. + void ParseExtensionElement(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context = null); + + /// + /// Attempts to use an extension to parse the element, with support for setting component keypath. + /// + /// Element containing element to be parsed. + /// Element to be parsed. + /// Extra information about the context in which this element is being parsed. + ComponentKeyPath ParsePossibleKeyPathExtensionElement(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context); + + /// + /// Process all children of the element looking for extensions and erroring on the unexpected. + /// + /// Element to parse children. + void ParseForExtensionElements(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement element); + + /// + /// Called when the compiler encounters an unexpected attribute. + /// + /// Parent element that found unexpected attribute. + /// Unexpected attribute. + void UnexpectedAttribute(XElement element, XAttribute attribute); + + /// + /// Called when the compiler encounters an unexpected child element. + /// + /// Parent element that found unexpected child. + /// Unexpected child element. + void UnexpectedElement(XElement parentElement, XElement childElement); + } +} -- cgit v1.2.3-55-g6feb