// 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. Row 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); } }