| 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 WixToolset.Data; |
| 8 | using WixToolset.Extensibility.Data; |
| 9 | |
| 10 | /// <summary> |
| 11 | /// Interface provided to help backend extensions. |
| 12 | /// </summary> |
| 13 | public interface IBackendHelper : ILayoutServices |
| 14 | { |
| 15 | /// <summary> |
| 16 | /// Creates a MSI compatible GUID. |
| 17 | /// </summary> |
| 18 | /// <returns>Creates an uppercase GUID with braces.</returns> |
| 19 | string CreateGuid(); |
| 20 | |
| 21 | /// <summary> |
| 22 | /// Creates a version 3 name-based UUID. |
| 23 | /// </summary> |
| 24 | /// <param name="namespaceGuid">The namespace UUID.</param> |
| 25 | /// <param name="value">The value.</param> |
| 26 | /// <returns>The generated GUID for the given namespace and value.</returns> |
| 27 | string CreateGuid(Guid namespaceGuid, string value); |
| 28 | |
| 29 | /// <summary> |
| 30 | /// Creates a resolved directory. |
| 31 | /// </summary> |
| 32 | /// <param name="directoryParent">Directory parent identifier.</param> |
| 33 | /// <param name="name">Name of directory.</param> |
| 34 | /// <returns>Resolved directory.</returns> |
| 35 | IResolvedDirectory CreateResolvedDirectory(string directoryParent, string name); |
| 36 | |
| 37 | /// <summary> |
| 38 | /// Extracts embedded files. |
| 39 | /// </summary> |
| 40 | /// <param name="embeddedFiles">Embedded files to extract.</param> |
| 41 | /// <returns><c>ITrackedFile</c> for each embedded file extracted.</returns> |
| 42 | IReadOnlyList<ITrackedFile> ExtractEmbeddedFiles(IEnumerable<IExpectedExtractFile> embeddedFiles); |
| 43 | |
| 44 | /// <summary> |
| 45 | /// Generate an identifier by hashing data from the row. |
| 46 | /// </summary> |
| 47 | /// <param name="prefix">Three letter or less prefix for generated row identifier.</param> |
| 48 | /// <param name="args">Information to hash.</param> |
| 49 | /// <returns>The generated identifier.</returns> |
| 50 | string GenerateIdentifier(string prefix, params string[] args); |
| 51 | |
| 52 | /// <summary> |
| 53 | /// Gets a valid code page from the given web name or integer value. |
| 54 | /// </summary> |
| 55 | /// <param name="value">A code page web name or integer value as a string.</param> |
| 56 | /// <param name="allowNoChange">Whether to allow -1 which does not change the database code pages. This may be the case with wxl files.</param> |
| 57 | /// <param name="onlyAnsi">Whether to allow Unicode (UCS) or UTF code pages.</param> |
| 58 | /// <param name="sourceLineNumbers">Source line information for the current authoring.</param> |
| 59 | /// <returns>A valid code page number.</returns> |
| 60 | /// <exception cref="ArgumentOutOfRangeException">The value is an integer less than 0 or greater than 65535.</exception> |
| 61 | /// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception> |
| 62 | /// <exception cref="NotSupportedException">The value doesn't not represent a valid code page name or integer value.</exception> |
| 63 | /// <exception cref="WixException">The code page is invalid for summary information.</exception> |
| 64 | int GetValidCodePage(string value, bool allowNoChange = false, bool onlyAnsi = false, SourceLineNumber sourceLineNumbers = null); |
| 65 | |
| 66 | /// <summary> |
| 67 | /// Get a source/target and short/long file name from an MSI Filename column. |
| 68 | /// </summary> |
| 69 | /// <param name="value">The Filename value.</param> |
| 70 | /// <param name="source">true to get a source name; false to get a target name</param> |
| 71 | /// <param name="longName">true to get a long name; false to get a short name</param> |
| 72 | /// <returns>The requesed file name.</returns> |
| 73 | string GetMsiFileName(string value, bool source, bool longName); |
| 74 | |
| 75 | /// <summary> |
| 76 | /// Verifies if an identifier is a valid binder variable name. |
| 77 | /// </summary> |
| 78 | /// <param name="variable">Binder variable name to verify.</param> |
| 79 | /// <returns>True if the identifier is a valid binder variable name.</returns> |
| 80 | bool IsValidBinderVariable(string variable); |
| 81 | |
| 82 | /// <summary> |
| 83 | /// Verifies the given string is a valid 4-part version. |
| 84 | /// </summary> |
| 85 | /// <param name="version">The version to verify.</param> |
| 86 | /// <returns>True if version is a valid 4-part version.</returns> |
| 87 | bool IsValidFourPartVersion(string version); |
| 88 | |
| 89 | /// <summary> |
| 90 | /// Verifies the given string is a valid MSI product version. |
| 91 | /// </summary> |
| 92 | /// <param name="version">The MSI product version to verify.</param> |
| 93 | /// <returns>True if version is a valid MSI product version</returns> |
| 94 | bool IsValidMsiProductVersion(string version); |
| 95 | |
| 96 | /// <summary> |
| 97 | /// Verifies the given string is a valid WiX version. |
| 98 | /// </summary> |
| 99 | /// <param name="version">The version to verify.</param> |
| 100 | /// <returns>True if version is a valid WiX version.</returns> |
| 101 | bool IsValidWixVersion(string version); |
| 102 | |
| 103 | /// <summary> |
| 104 | /// Determines if value is a valid identifier. |
| 105 | /// </summary> |
| 106 | /// <param name="id">Identifier to validate.</param> |
| 107 | /// <returns>True if valid identifier, otherwise false.</returns> |
| 108 | bool IsValidIdentifier(string id); |
| 109 | |
| 110 | /// <summary> |
| 111 | /// Verifies the given string is a valid long filename. |
| 112 | /// </summary> |
| 113 | /// <param name="filename">The filename to verify.</param> |
| 114 | /// <param name="allowWildcards">Allow wildcards in the filename.</param> |
| 115 | /// <param name="allowRelative">Allow long file name to be a relative path.</param> |
| 116 | /// <returns>True if filename is a valid long filename.</returns> |
| 117 | bool IsValidLongFilename(string filename, bool allowWildcards, bool allowRelative); |
| 118 | |
| 119 | /// <summary> |
| 120 | /// Verifies the given string is a valid short filename. |
| 121 | /// </summary> |
| 122 | /// <param name="filename">The filename to verify.</param> |
| 123 | /// <param name="allowWildcards">Allow wildcards in the filename.</param> |
| 124 | /// <returns>True if filename is a valid short filename.</returns> |
| 125 | bool IsValidShortFilename(string filename, bool allowWildcards); |
| 126 | |
| 127 | /// <summary> |
| 128 | /// Resolve delayed fields. |
| 129 | /// </summary> |
| 130 | /// <param name="delayedFields">The fields which had resolution delayed.</param> |
| 131 | /// <param name="variableCache">The cached variable values used when resolving delayed fields.</param> |
| 132 | void ResolveDelayedFields(IEnumerable<IDelayedField> delayedFields, Dictionary<string, string> variableCache); |
| 133 | |
| 134 | /// <summary> |
| 135 | /// Get the source/target and short/long file names from an MSI Filename column. |
| 136 | /// </summary> |
| 137 | /// <param name="value">The Filename value.</param> |
| 138 | /// <returns>An array of strings of length 4. The contents are: short target, long target, short source, and long source.</returns> |
| 139 | /// <remarks> |
| 140 | /// If any particular file name part is not parsed, its set to null in the appropriate location of the returned array of strings. |
| 141 | /// Thus the returned array will always be of length 4. |
| 142 | /// </remarks> |
| 143 | string[] SplitMsiFileName(string value); |
| 144 | |
| 145 | /// <summary> |
| 146 | /// Tries to parse a version from the provided version string. |
| 147 | /// </summary> |
| 148 | /// <param name="version">The version to verify and parse.</param> |
| 149 | /// <param name="parsedVersion">The parsed result if possible, otherwise null.</param> |
| 150 | /// <returns>True if the version was able to parsed, otherwise false.</returns> |
| 151 | bool TryParseFourPartVersion(string version, out string parsedVersion); |
| 152 | |
| 153 | /// <summary> |
| 154 | /// Tries to parse an MSI product version from the provided version string. |
| 155 | /// </summary> |
| 156 | /// <param name="version">The version to verify and parse.</param> |
| 157 | /// <param name="strict">Indicates whether to return a strict (255.255.65535) product version or any valid product version (255.255.65535.*).</param> |
| 158 | /// <param name="parsedVersion">The parsed result if possible, otherwise null.</param> |
| 159 | /// <returns>True if the version was able to parsed as an product version, otherwise false.</returns> |
| 160 | bool TryParseMsiProductVersion(string version, bool strict, out string parsedVersion); |
| 161 | } |
| 162 | } |