| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.Extensibility.Services |
| 4 | { |
| 5 | using System; |
| 6 | using System.Collections.Generic; |
| 7 | using System.Xml.Linq; |
| 8 | using WixToolset.Data; |
| 9 | using WixToolset.Data.Symbols; |
| 10 | using WixToolset.Data.WindowsInstaller; |
| 11 | using WixToolset.Extensibility.Data; |
| 12 | |
| 13 | /// <summary> |
| 14 | /// Interface provided to help compiler and optimizer extensions parse. |
| 15 | /// </summary> |
| 16 | public interface IParseHelper |
| 17 | { |
| 18 | /// <summary> |
| 19 | /// Creates a version 3 name-based UUID. |
| 20 | /// </summary> |
| 21 | /// <param name="namespaceGuid">The namespace UUID.</param> |
| 22 | /// <param name="value">The value.</param> |
| 23 | /// <returns>The generated GUID for the given namespace and value.</returns> |
| 24 | string CreateGuid(Guid namespaceGuid, string value); |
| 25 | |
| 26 | /// <summary> |
| 27 | /// Create an identifier by hashing data from the row. |
| 28 | /// </summary> |
| 29 | /// <param name="prefix">Three letter or less prefix for generated row identifier.</param> |
| 30 | /// <param name="args">Information to hash.</param> |
| 31 | /// <returns>The new identifier.</returns> |
| 32 | Identifier CreateIdentifier(string prefix, params string[] args); |
| 33 | |
| 34 | /// <summary> |
| 35 | /// Create an identifier based on passed file name |
| 36 | /// </summary> |
| 37 | /// <param name="filename">File name to generate identifier from</param> |
| 38 | /// <returns>The new identifier.</returns> |
| 39 | Identifier CreateIdentifierFromFilename(string filename); |
| 40 | |
| 41 | /// <summary> |
| 42 | /// Append a suffix to the given name based on the current platform. |
| 43 | /// If the current platform is not in the supported platforms, then it returns null. |
| 44 | /// </summary> |
| 45 | /// <param name="name">The base name for the identifier.</param> |
| 46 | /// <param name="currentPlatform">The platform being compiled.</param> |
| 47 | /// <param name="supportedPlatforms">The platforms for which there are specialized implementations.</param> |
| 48 | /// <returns>The generated identifier value, or null if the current platform isn't supported.</returns> |
| 49 | string CreateIdentifierValueFromPlatform(string name, Platform currentPlatform, BurnPlatforms supportedPlatforms); |
| 50 | |
| 51 | /// <summary> |
| 52 | /// Creates a symbol in the section. |
| 53 | /// </summary> |
| 54 | /// <param name="section">Section to add the new symbol to.</param> |
| 55 | /// <param name="sourceLineNumbers">Source and line number of current symbol.</param> |
| 56 | /// <param name="symbolName">Name of symbol definition.</param> |
| 57 | /// <param name="identifier">Optional identifier for the symbol.</param> |
| 58 | /// <returns>New symbol.</returns> |
| 59 | IntermediateSymbol CreateSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, string symbolName, Identifier identifier = null); |
| 60 | |
| 61 | /// <summary> |
| 62 | /// Creates a symbol in the section. |
| 63 | /// </summary> |
| 64 | /// <param name="section">Section to add the new symbol to.</param> |
| 65 | /// <param name="sourceLineNumbers">Source and line number of current symbol.</param> |
| 66 | /// <param name="symbolDefinition">Symbol definition to create from.</param> |
| 67 | /// <param name="identifier">Optional identifier for the symbol.</param> |
| 68 | /// <returns>New symbol.</returns> |
| 69 | IntermediateSymbol CreateSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, Identifier identifier = null); |
| 70 | |
| 71 | /// <summary> |
| 72 | /// Creates a directory row from a name. |
| 73 | /// </summary> |
| 74 | /// <param name="section">Section to add the new symbol to.</param> |
| 75 | /// <param name="sourceLineNumbers">Source line information.</param> |
| 76 | /// <param name="id">Optional identifier for the new row.</param> |
| 77 | /// <param name="parentId">Optional identifier for the parent row.</param> |
| 78 | /// <param name="name">Long name of the directory.</param> |
| 79 | /// <param name="shortName">Optional short name of the directory.</param> |
| 80 | /// <param name="sourceName">Optional source name for the directory.</param> |
| 81 | /// <param name="shortSourceName">Optional short source name for the directory.</param> |
| 82 | /// <returns>Identifier for the newly created row.</returns> |
| 83 | Identifier CreateDirectorySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null); |
| 84 | |
| 85 | /// <summary> |
| 86 | /// Creates directories using the inline directory syntax. |
| 87 | /// </summary> |
| 88 | /// <param name="section">Section to add the new symbol to.</param> |
| 89 | /// <param name="sourceLineNumbers">Source line information.</param> |
| 90 | /// <param name="attribute">Attribute containing the inline syntax.</param> |
| 91 | /// <param name="parentId">Optional identifier of parent directory.</param> |
| 92 | /// <param name="inlineSyntax">Optional inline syntax to override attribute's value.</param> |
| 93 | /// <param name="sectionCachedInlinedDirectoryIds">Mapping of inline directory syntax to ids for the section.</param> |
| 94 | /// <returns>Identifier of the leaf directory created.</returns> |
| 95 | string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId, string inlineSyntax, IDictionary<string, string> sectionCachedInlinedDirectoryIds); |
| 96 | |
| 97 | /// <summary> |
| 98 | /// Creates a Registry symbol in the active section. |
| 99 | /// </summary> |
| 100 | /// <param name="section">Active section.</param> |
| 101 | /// <param name="sourceLineNumbers">Source and line number of the current symbol.</param> |
| 102 | /// <param name="root">The registry entry root.</param> |
| 103 | /// <param name="key">The registry entry key.</param> |
| 104 | /// <param name="name">The registry entry name.</param> |
| 105 | /// <param name="value">The registry entry value.</param> |
| 106 | /// <param name="componentId">The component which will control installation/uninstallation of the registry entry.</param> |
| 107 | /// <param name="valueType">The registry value type. Default is string.</param> |
| 108 | /// <param name="valueAction">The way to apply the registry value. Default is write.</param> |
| 109 | Identifier CreateRegistrySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, RegistryRootType root, string key, string name, string value, string componentId, RegistryValueType valueType = RegistryValueType.String, RegistryValueActionType valueAction = RegistryValueActionType.Write); |
| 110 | |
| 111 | /// <summary> |
| 112 | /// Creates a numeric Registry symbol in the active section. |
| 113 | /// </summary> |
| 114 | /// <param name="section">Active section.</param> |
| 115 | /// <param name="sourceLineNumbers">Source and line number of the current symbol.</param> |
| 116 | /// <param name="root">The registry entry root.</param> |
| 117 | /// <param name="key">The registry entry key.</param> |
| 118 | /// <param name="name">The registry entry name.</param> |
| 119 | /// <param name="value">The numeric registry entry value.</param> |
| 120 | /// <param name="componentId">The component which will control installation/uninstallation of the registry entry.</param> |
| 121 | Identifier CreateRegistrySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, RegistryRootType root, string key, string name, int value, string componentId); |
| 122 | |
| 123 | /// <summary> |
| 124 | /// Create a WixSimpleReference symbol in the active section. |
| 125 | /// </summary> |
| 126 | /// <param name="section">Active section.</param> |
| 127 | /// <param name="sourceLineNumbers">Source line information for the row.</param> |
| 128 | /// <param name="symbolName">The symbol name of the simple reference.</param> |
| 129 | /// <param name="primaryKey">The primary key of the simple reference.</param> |
| 130 | void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, string symbolName, string primaryKey); |
| 131 | |
| 132 | /// <summary> |
| 133 | /// Create a WixSimpleReference symbol in the active section. |
| 134 | /// </summary> |
| 135 | /// <param name="section">Active section.</param> |
| 136 | /// <param name="sourceLineNumbers">Source line information for the row.</param> |
| 137 | /// <param name="symbolName">The symbol name of the simple reference.</param> |
| 138 | /// <param name="primaryKeys">The primary keys of the simple reference.</param> |
| 139 | void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, string symbolName, params string[] primaryKeys); |
| 140 | |
| 141 | /// <summary> |
| 142 | /// Create a WixSimpleReference symbol in the active section. |
| 143 | /// </summary> |
| 144 | /// <param name="section">Active section.</param> |
| 145 | /// <param name="sourceLineNumbers">Source line information for the row.</param> |
| 146 | /// <param name="symbolDefinition">The symbol definition of the simple reference.</param> |
| 147 | /// <param name="primaryKey">The primary key of the simple reference.</param> |
| 148 | void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, string primaryKey); |
| 149 | |
| 150 | /// <summary> |
| 151 | /// Create a WixSimpleReference symbol in the active section. |
| 152 | /// </summary> |
| 153 | /// <param name="section">Active section.</param> |
| 154 | /// <param name="sourceLineNumbers">Source line information for the row.</param> |
| 155 | /// <param name="symbolDefinition">The symbol definition of the simple reference.</param> |
| 156 | /// <param name="primaryKeys">The primary keys of the simple reference.</param> |
| 157 | void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, params string[] primaryKeys); |
| 158 | |
| 159 | /// <summary> |
| 160 | /// Create a reference in the specified section for a custom action specialized for specific platforms, |
| 161 | /// given standard prefixes for naming and suffixes for platforms. |
| 162 | /// </summary> |
| 163 | /// <param name="sourceLineNumbers">Source line information.</param> |
| 164 | /// <param name="section">Section to create the reference in.</param> |
| 165 | /// <param name="customAction">The custom action base name.</param> |
| 166 | /// <param name="platform">The platform being compiled.</param> |
| 167 | /// <param name="supportedPlatforms">The platforms for which there are specialized custom actions.</param> |
| 168 | void CreateCustomActionReference(SourceLineNumber sourceLineNumbers, IntermediateSection section, string customAction, Platform platform, CustomActionPlatforms supportedPlatforms); |
| 169 | |
| 170 | /// <summary> |
| 171 | /// Creates WixComplexReference and WixGroup symbols in the active section. |
| 172 | /// </summary> |
| 173 | /// <param name="section">Section to create the reference in.</param> |
| 174 | /// <param name="sourceLineNumbers">Source line information.</param> |
| 175 | /// <param name="parentType">The parent type.</param> |
| 176 | /// <param name="parentId">The parent id.</param> |
| 177 | /// <param name="parentLanguage">The parent language.</param> |
| 178 | /// <param name="childType">The child type.</param> |
| 179 | /// <param name="childId">The child id.</param> |
| 180 | /// <param name="isPrimary">Whether the child is primary.</param> |
| 181 | void CreateComplexReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary); |
| 182 | |
| 183 | /// <summary> |
| 184 | /// A symbol in the WixGroup table is added for this child node and its parent node. |
| 185 | /// </summary> |
| 186 | /// <param name="section">Section to create the reference in.</param> |
| 187 | /// <param name="sourceLineNumbers">Source line information for the row.</param> |
| 188 | /// <param name="parentType">Type of child's complex reference parent.</param> |
| 189 | /// <param name="parentId">Id of the parenet node.</param> |
| 190 | /// <param name="childType">Complex reference type of child</param> |
| 191 | /// <param name="childId">Id of the Child Node.</param> |
| 192 | void CreateWixGroupSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType childType, string childId); |
| 193 | |
| 194 | /// <summary> |
| 195 | /// Creates a symbol in the WixSearch table. |
| 196 | /// </summary> |
| 197 | /// <param name="section">Section to create the reference in.</param> |
| 198 | /// <param name="sourceLineNumbers">Source line number for the search element.</param> |
| 199 | /// <param name="elementName">Name of search element.</param> |
| 200 | /// <param name="id">Identifier of the search.</param> |
| 201 | /// <param name="variable">The Burn variable to store the result into.</param> |
| 202 | /// <param name="condition">A condition to test before evaluating the search.</param> |
| 203 | /// <param name="after">The search that this one will execute after.</param> |
| 204 | /// <param name="bootstrapperExtensionId">The id of the bootstrapper extension that handles this search.</param> |
| 205 | void CreateWixSearchSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, string elementName, Identifier id, string variable, string condition, string after, string bootstrapperExtensionId); |
| 206 | |
| 207 | /// <summary> |
| 208 | /// |
| 209 | /// </summary> |
| 210 | /// <param name="section">Section to create the reference in.</param> |
| 211 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> |
| 212 | /// <param name="id">Identifier of the search (key into the WixSearch table)</param> |
| 213 | /// <param name="parentId">Identifier of the search that comes before (key into the WixSearch table)</param> |
| 214 | /// <param name="attributes">Further details about the relation between id and parentId.</param> |
| 215 | void CreateWixSearchRelationSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, int attributes); |
| 216 | |
| 217 | /// <summary> |
| 218 | /// Checks if the string contains a property (i.e. "foo[Property]bar") |
| 219 | /// </summary> |
| 220 | /// <param name="possibleProperty">String to evaluate for properties.</param> |
| 221 | /// <returns>True if a property is found in the string.</returns> |
| 222 | bool ContainsProperty(string possibleProperty); |
| 223 | |
| 224 | /// <summary> |
| 225 | /// Add the appropriate symbols to make sure that the given table shows up in the resulting output. |
| 226 | /// </summary> |
| 227 | /// <param name="section">Active section.</param> |
| 228 | /// <param name="sourceLineNumbers">Source line numbers.</param> |
| 229 | /// <param name="tableName">Name of the table to ensure existance of.</param> |
| 230 | void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName); |
| 231 | |
| 232 | /// <summary> |
| 233 | /// Add the appropriate symbols to make sure that the given table shows up in the resulting output. |
| 234 | /// </summary> |
| 235 | /// <param name="section">Active section.</param> |
| 236 | /// <param name="sourceLineNumbers">Source line numbers.</param> |
| 237 | /// <param name="tableDefinition">Definition of the table to ensure existance of.</param> |
| 238 | void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition); |
| 239 | |
| 240 | /// <summary> |
| 241 | /// Get an attribute value and displays an error if the value is empty by default. |
| 242 | /// </summary> |
| 243 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 244 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 245 | /// <param name="emptyRule">A rule for the contents of the value. If the contents do not follow the rule, an error is thrown.</param> |
| 246 | /// <returns>The attribute's value.</returns> |
| 247 | string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule = EmptyRule.CanBeWhitespaceOnly); |
| 248 | |
| 249 | /// <summary> |
| 250 | /// Gets a bundle variable name identifier and displays an error for an illegal value. |
| 251 | /// </summary> |
| 252 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 253 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 254 | /// <returns>The attribute's identifier value or a special value if an error occurred.</returns> |
| 255 | Identifier GetAttributeBundleVariableNameIdentifier(SourceLineNumber sourceLineNumbers, XAttribute attribute); |
| 256 | |
| 257 | /// <summary> |
| 258 | /// Gets a bundle variable name value and displays an error for an illegal value. |
| 259 | /// </summary> |
| 260 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 261 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 262 | /// <param name="nameRule">A rule for the contents of the value. If the contents do not follow the rule, an error is thrown.</param> |
| 263 | /// <returns>The attribute's value.</returns> |
| 264 | string GetAttributeBundleVariableNameValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, BundleVariableNameRule nameRule = BundleVariableNameRule.CanBeWellKnown | BundleVariableNameRule.CanHaveReservedPrefix); |
| 265 | |
| 266 | /// <summary> |
| 267 | /// Get a guid attribute value and displays an error for an illegal guid value. |
| 268 | /// </summary> |
| 269 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 270 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 271 | /// <param name="generatable">Determines whether the guid can be automatically generated.</param> |
| 272 | /// <param name="canBeEmpty">If true, no error is raised on empty value. If false, an error is raised.</param> |
| 273 | /// <returns>The attribute's guid value or a special value if an error occurred.</returns> |
| 274 | string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false); |
| 275 | |
| 276 | /// <summary> |
| 277 | /// Get an identifier attribute value and displays an error for an illegal identifier value. |
| 278 | /// </summary> |
| 279 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 280 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 281 | /// <returns>The attribute's identifier value or a special value if an error occurred.</returns> |
| 282 | Identifier GetAttributeIdentifier(SourceLineNumber sourceLineNumbers, XAttribute attribute); |
| 283 | |
| 284 | /// <summary> |
| 285 | /// Get an identifier attribute value and displays an error for an illegal identifier value. |
| 286 | /// </summary> |
| 287 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 288 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 289 | /// <returns>The attribute's identifier value or a special value if an error occurred.</returns> |
| 290 | string GetAttributeIdentifierValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); |
| 291 | |
| 292 | /// <summary> |
| 293 | /// Get an integer attribute value and displays an error for an illegal integer value. |
| 294 | /// </summary> |
| 295 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 296 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 297 | /// <param name="minimum">The minimum legal value.</param> |
| 298 | /// <param name="maximum">The maximum legal value.</param> |
| 299 | /// <returns>The attribute's integer value or a special value if an error occurred during conversion.</returns> |
| 300 | int GetAttributeIntegerValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, int minimum, int maximum); |
| 301 | |
| 302 | /// <summary> |
| 303 | /// Get a long integral attribute value and displays an error for an illegal long value. |
| 304 | /// </summary> |
| 305 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 306 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 307 | /// <param name="minimum">The minimum legal value.</param> |
| 308 | /// <param name="maximum">The maximum legal value.</param> |
| 309 | /// <returns>The attribute's long value or a special value if an error occurred during conversion.</returns> |
| 310 | long GetAttributeLongValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, long minimum, long maximum); |
| 311 | |
| 312 | /// <summary> |
| 313 | /// Gets a long filename value and displays an error for an illegal long filename value. |
| 314 | /// </summary> |
| 315 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 316 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 317 | /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param> |
| 318 | /// <param name="allowRelative">true if relative paths are allowed in the filename.</param> |
| 319 | /// <returns>The attribute's long filename value.</returns> |
| 320 | string GetAttributeLongFilename(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowWildcards = false, bool allowRelative = false); |
| 321 | |
| 322 | /// <summary> |
| 323 | /// Gets a RegistryRootType value and displays an error for an illegal value. |
| 324 | /// </summary> |
| 325 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 326 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 327 | /// <param name="allowHkmu">Whether HKMU is returned as -1 (true), or treated as an error (false).</param> |
| 328 | /// <returns>The attribute's RegisitryRootType value.</returns> |
| 329 | RegistryRootType? GetAttributeRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu); |
| 330 | |
| 331 | /// <summary> |
| 332 | /// Gets a version value or possibly a binder variable and displays an error for an illegal version value. |
| 333 | /// </summary> |
| 334 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 335 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 336 | /// <returns>The attribute's version value.</returns> |
| 337 | string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); |
| 338 | |
| 339 | /// <summary> |
| 340 | /// Gets a yes/no value and displays an error for an illegal yes/no value. |
| 341 | /// </summary> |
| 342 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 343 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 344 | /// <returns>The attribute's YesNoType value.</returns> |
| 345 | YesNoType GetAttributeYesNoValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); |
| 346 | |
| 347 | /// <summary> |
| 348 | /// Gets a yes/no/default value and displays an error for an illegal yes/no/default value. |
| 349 | /// </summary> |
| 350 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 351 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 352 | /// <returns>The attribute's YesNoType value.</returns> |
| 353 | YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); |
| 354 | |
| 355 | /// <summary> |
| 356 | /// Gets a source line number for an element. |
| 357 | /// </summary> |
| 358 | /// <param name="element">Element to get source line number.</param> |
| 359 | /// <returns>Source line number.</returns> |
| 360 | SourceLineNumber GetSourceLineNumbers(XElement element); |
| 361 | |
| 362 | /// <summary> |
| 363 | /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace. |
| 364 | /// </summary> |
| 365 | /// <param name="node">The node to ensure inner text is a condition.</param> |
| 366 | /// <returns>The value converted into a safe condition.</returns> |
| 367 | [Obsolete] |
| 368 | string GetConditionInnerText(XElement node); |
| 369 | |
| 370 | /// <summary> |
| 371 | /// Get an element's inner text and trims any extra whitespace. |
| 372 | /// </summary> |
| 373 | /// <param name="element">The element with inner text to be trimmed.</param> |
| 374 | /// <returns>The node's inner text trimmed.</returns> |
| 375 | [Obsolete] |
| 376 | string GetTrimmedInnerText(XElement element); |
| 377 | |
| 378 | /// <summary> |
| 379 | /// Validates that the element does not contain inner text. |
| 380 | /// </summary> |
| 381 | /// <param name="element">Element to check for inner text.</param> |
| 382 | void InnerTextDisallowed(XElement element); |
| 383 | |
| 384 | /// <summary> |
| 385 | /// Validates that the element does not contain inner text and suggests which attribute to use instead. |
| 386 | /// </summary> |
| 387 | /// <param name="element">Element to check for inner text.</param> |
| 388 | /// <param name="attributeName">Name of attribute to use instead of inner text.</param> |
| 389 | void InnerTextDisallowed(XElement element, string attributeName); |
| 390 | |
| 391 | /// <summary> |
| 392 | /// Verifies that a value is a legal identifier. |
| 393 | /// </summary> |
| 394 | /// <param name="value">The value to verify.</param> |
| 395 | /// <returns>true if the value is an identifier; false otherwise.</returns> |
| 396 | bool IsValidIdentifier(string value); |
| 397 | |
| 398 | /// <summary> |
| 399 | /// Verifies if an identifier is a valid loc identifier. |
| 400 | /// </summary> |
| 401 | /// <param name="identifier">Identifier to verify.</param> |
| 402 | /// <returns>True if the identifier is a valid loc identifier.</returns> |
| 403 | bool IsValidLocIdentifier(string identifier); |
| 404 | |
| 405 | /// <summary> |
| 406 | /// Verifies if a filename is a valid long filename. |
| 407 | /// </summary> |
| 408 | /// <param name="filename">Filename to verify.</param> |
| 409 | /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param> |
| 410 | /// <param name="allowRelative">true if relative paths are allowed in the filename.</param> |
| 411 | /// <returns>True if the filename is a valid long filename</returns> |
| 412 | bool IsValidLongFilename(string filename, bool allowWildcards = false, bool allowRelative = false); |
| 413 | |
| 414 | /// <summary> |
| 415 | /// Verifies if a filename is a valid short filename. |
| 416 | /// </summary> |
| 417 | /// <param name="filename">Filename to verify.</param> |
| 418 | /// <param name="allowWildcards">Indicates whether wildcards are allowed in the filename.</param> |
| 419 | /// <returns>True if the filename is a valid short filename</returns> |
| 420 | bool IsValidShortFilename(string filename, bool allowWildcards); |
| 421 | |
| 422 | /// <summary> |
| 423 | /// Attempts to use an extension to parse the attribute. |
| 424 | /// </summary> |
| 425 | /// <param name="extensions"></param> |
| 426 | /// <param name="intermediate">Parent intermediate.</param> |
| 427 | /// <param name="section">Parent section.</param> |
| 428 | /// <param name="element">Element containing attribute to be parsed.</param> |
| 429 | /// <param name="attribute">Attribute to be parsed.</param> |
| 430 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> |
| 431 | void ParseExtensionAttribute(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement element, XAttribute attribute, IDictionary<string, string> context = null); |
| 432 | |
| 433 | /// <summary> |
| 434 | /// Attempts to use an extension to parse the element. |
| 435 | /// </summary> |
| 436 | /// <param name="extensions"></param> |
| 437 | /// <param name="intermediate">Parent intermediate.</param> |
| 438 | /// <param name="section">Parent section.</param> |
| 439 | /// <param name="parentElement">Element containing element to be parsed.</param> |
| 440 | /// <param name="element">Element to be parsed.</param> |
| 441 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> |
| 442 | void ParseExtensionElement(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context = null); |
| 443 | |
| 444 | /// <summary> |
| 445 | /// Attempts to use an extension to parse the element, with support for setting component keypath. |
| 446 | /// </summary> |
| 447 | /// <param name="extensions"></param> |
| 448 | /// <param name="intermediate">Parent intermediate.</param> |
| 449 | /// <param name="section">Parent section.</param> |
| 450 | /// <param name="parentElement">Element containing element to be parsed.</param> |
| 451 | /// <param name="element">Element to be parsed.</param> |
| 452 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> |
| 453 | IComponentKeyPath ParsePossibleKeyPathExtensionElement(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context); |
| 454 | |
| 455 | /// <summary> |
| 456 | /// Process all children of the element looking for extensions and erroring on the unexpected. |
| 457 | /// </summary> |
| 458 | /// <param name="extensions"></param> |
| 459 | /// <param name="intermediate">Parent intermediate.</param> |
| 460 | /// <param name="section">Parent section.</param> |
| 461 | /// <param name="element">Element to parse children.</param> |
| 462 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> |
| 463 | void ParseForExtensionElements(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement element, IDictionary<string, string> context = null); |
| 464 | |
| 465 | /// <summary> |
| 466 | /// Schedules an action symbol. |
| 467 | /// </summary> |
| 468 | /// <param name="section">Section to add the symbol to.</param> |
| 469 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 470 | /// <param name="access">Access modifier for the scheduled action.</param> |
| 471 | /// <param name="sequence">Sequence to add the action to.</param> |
| 472 | /// <param name="name">Name of action.</param> |
| 473 | /// <param name="condition">Optional condition of action.</param> |
| 474 | /// <param name="beforeAction">Optional action to schedule before.</param> |
| 475 | /// <param name="afterAction">Option action to schedule after.</param> |
| 476 | /// <param name="overridable">Optional overridable flag.</param> |
| 477 | WixActionSymbol ScheduleActionSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, AccessModifier access, SequenceTable sequence, string name, string condition, string beforeAction, string afterAction, bool overridable = false); |
| 478 | |
| 479 | /// <summary> |
| 480 | /// Called when the compiler encounters an unexpected attribute. |
| 481 | /// </summary> |
| 482 | /// <param name="element">Parent element that found unexpected attribute.</param> |
| 483 | /// <param name="attribute">Unexpected attribute.</param> |
| 484 | void UnexpectedAttribute(XElement element, XAttribute attribute); |
| 485 | |
| 486 | /// <summary> |
| 487 | /// Called when the compiler encounters an unexpected child element. |
| 488 | /// </summary> |
| 489 | /// <param name="parentElement">Parent element that found unexpected child.</param> |
| 490 | /// <param name="childElement">Unexpected child element.</param> |
| 491 | void UnexpectedElement(XElement parentElement, XElement childElement); |
| 492 | } |
| 493 | } |