From f4af6bf27abaaac7f0508ce2beafb31b5a64b53f Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sun, 14 Mar 2021 07:30:15 -0700 Subject: Minimize public surface area of Core Part of wixtoolset/issues#6374 --- src/WixToolset.Extensibility/Data/IFileFacade.cs | 126 +++++++++++++++++++++ .../Services/IBackendHelper.cs | 125 ++++++++++++++++++++ .../Services/IParseHelper.cs | 15 +-- .../Services/IPathResolver.cs | 5 +- .../Services/IWindowsInstallerBackendHelper.cs | 2 +- .../Services/IWixBranding.cs | 26 +++++ 6 files changed, 283 insertions(+), 16 deletions(-) create mode 100644 src/WixToolset.Extensibility/Data/IFileFacade.cs create mode 100644 src/WixToolset.Extensibility/Services/IWixBranding.cs (limited to 'src') diff --git a/src/WixToolset.Extensibility/Data/IFileFacade.cs b/src/WixToolset.Extensibility/Data/IFileFacade.cs new file mode 100644 index 00000000..fea00d4e --- /dev/null +++ b/src/WixToolset.Extensibility/Data/IFileFacade.cs @@ -0,0 +1,126 @@ +// 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.Data +{ + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Data.WindowsInstaller.Rows; + + /// + /// Interface that provides a common facade over FileSymbol and FileRow. + /// + public interface IFileFacade + { + /// + /// Reference to assembly application for this file. + /// + string AssemblyApplicationFileRef { get; } + + /// + /// Reference to assembly manifest for this file. + /// + string AssemblyManifestFileRef { get; } + + /// + /// List of assembly name values in the file. + /// + List AssemblyNames { get; set; } + + /// + /// Optionally indicates what sort of assembly the file is. + /// + AssemblyType? AssemblyType { get; } + + /// + /// Component containing the file. + /// + string ComponentRef { get; } + + /// + /// Indicates whether the file is compressed. + /// + bool Compressed { get; } + + /// + /// Disk Id for the file. + /// + int DiskId { get; set; } + + /// + /// Name of the file. + /// + string FileName { get; } + + /// + /// Size of the file. + /// + int FileSize { get; set; } + + /// + /// Indicates whether the file came from a merge module. + /// + bool FromModule { get; } + + /// + /// Indicates whether the file came from a transform. + /// + bool FromTransform { get; } + + /// + /// Hash symbol of the file. + /// + MsiFileHashSymbol Hash { get; set; } + + /// + /// Underlying identifier of the file. + /// + Identifier Identifier { get; } + + /// + /// Helper accessor for the Id of the Identifier. + /// + string Id { get; } + + /// + /// Language of the file. + /// + string Language { get; set; } + + /// + /// Optional patch group for the file. + /// + int? PatchGroup { get; } + + /// + /// Sequence of the file. + /// + int Sequence { get; set; } + + /// + /// Source line number that define the file. + /// + SourceLineNumber SourceLineNumber { get; } + + /// + /// Source to the file. + /// + string SourcePath { get; } + + /// + /// Indicates whether the file is to be uncompressed. + /// + bool Uncompressed { get; } + + /// + /// Version of the file. + /// + string Version { get; set; } + + /// + /// Gets the underlying FileRow if one is present. + /// + /// FileRow if one is present, otherwise throws. + FileRow GetFileRow(); + } +} diff --git a/src/WixToolset.Extensibility/Services/IBackendHelper.cs b/src/WixToolset.Extensibility/Services/IBackendHelper.cs index 0c8578b2..ce3ddc89 100644 --- a/src/WixToolset.Extensibility/Services/IBackendHelper.cs +++ b/src/WixToolset.Extensibility/Services/IBackendHelper.cs @@ -3,7 +3,10 @@ namespace WixToolset.Extensibility.Services { using System; + using System.Collections.Generic; using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility.Data; /// @@ -11,6 +14,28 @@ namespace WixToolset.Extensibility.Services /// public interface IBackendHelper { + /// + /// Creates a file facade from a FileSymbol and possible AssemblySymbol. + /// + /// FileSymbol backing the facade. + /// AssemblySymbol backing the facade. + /// + IFileFacade CreateFileFacade(FileSymbol file, AssemblySymbol assembly); + + /// + /// Creates a file facade from a File row. + /// + /// FileRow + /// New IFileFacade. + IFileFacade CreateFileFacade(FileRow fileRow); + + /// + /// Creates a file facade from a Merge Module's File symbol. + /// + /// FileSymbol created from a Merge Module. + /// New IFileFacade. + IFileFacade CreateFileFacadeFromMergeModule(FileSymbol fileSymbol); + /// /// Creates a file transfer and marks it redundant if the source and destination are identical. /// @@ -20,6 +45,12 @@ namespace WixToolset.Extensibility.Services /// Optional source line numbers that requested the file transfer. IFileTransfer CreateFileTransfer(string source, string destination, bool move, SourceLineNumber sourceLineNumbers = null); + /// + /// Creates a MSI compatible GUID. + /// + /// Creates an uppercase GUID with braces. + string CreateGuid(); + /// /// Creates a version 3 name-based UUID. /// @@ -36,6 +67,21 @@ namespace WixToolset.Extensibility.Services /// Resolved directory. IResolvedDirectory CreateResolvedDirectory(string directoryParent, string name); + /// + /// Extracts embedded files. + /// + /// Embedded files to extract. + /// ITrackedFile for each embedded file extracted. + IEnumerable ExtractEmbeddedFiles(IEnumerable embeddedFiles); + + /// + /// 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 GenerateIdentifier(string prefix, params string[] args); + /// /// Validates path is relative and canonicalizes it. /// For example, "a\..\c\.\d.exe" => "c\d.exe". @@ -47,6 +93,85 @@ namespace WixToolset.Extensibility.Services /// The original value if not relative, otherwise the canonicalized relative path. string GetCanonicalRelativePath(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string relativePath); + /// + /// Gets a valid code page from the given web name or integer value. + /// + /// A code page web name or integer value as a string. + /// Whether to allow -1 which does not change the database code pages. This may be the case with wxl files. + /// Whether to allow Unicode (UCS) or UTF code pages. + /// Source line information for the current authoring. + /// A valid code page number. + /// The value is an integer less than 0 or greater than 65535. + /// is null. + /// The value doesn't not represent a valid code page name or integer value. + /// The code page is invalid for summary information. + int GetValidCodePage(string value, bool allowNoChange = false, bool onlyAnsi = false, SourceLineNumber sourceLineNumbers = null); + + /// + /// Get a source/target and short/long file name from an MSI Filename column. + /// + /// The Filename value. + /// true to get a source name; false to get a target name + /// true to get a long name; false to get a short name + /// The name. + string GetMsiFileName(string value, bool source, bool longName); + + /// + /// Verifies if an identifier is a valid binder variable name. + /// + /// Binder variable name to verify. + /// True if the identifier is a valid binder variable name. + bool IsValidBinderVariable(string variable); + + /// + /// Verifies the given string is a valid 4-part version module or bundle version. + /// + /// The version to verify. + /// True if version is a valid module or bundle version. + bool IsValidFourPartVersion(string version); + + /// + /// Determines if value is a valid identifier. + /// + /// Identifier to validate. + /// True if valid identifier, otherwise false. + bool IsValidIdentifier(string id); + + /// + /// Verifies the given string is a valid long filename. + /// + /// The filename to verify. + /// Allow wildcards in the filename. + /// Allow long file name to be a relative path. + /// True if filename is a valid long filename. + bool IsValidLongFilename(string filename, bool allowWildcards, bool allowRelative); + + /// + /// Verifies the given string is a valid short filename. + /// + /// The filename to verify. + /// Allow wildcards in the filename. + /// True if filename is a valid short filename. + bool IsValidShortFilename(string filename, bool allowWildcards); + + /// + /// Resolve delayed fields. + /// + /// The fields which had resolution delayed. + /// The cached variable values used when resolving delayed fields. + void ResolveDelayedFields(IEnumerable delayedFields, Dictionary variableCache); + + /// + /// Get the source/target and short/long file names from an MSI Filename column. + /// + /// The Filename value. + /// An array of strings of length 4. The contents are: short target, long target, short source, and long source. + /// + /// If any particular file name part is not parsed, its set to null in the appropriate location of the returned array of strings. + /// Thus the returned array will always be of length 4. + /// + string[] SplitMsiFileName(string value); + /// /// Creates a tracked file. /// diff --git a/src/WixToolset.Extensibility/Services/IParseHelper.cs b/src/WixToolset.Extensibility/Services/IParseHelper.cs index d64efecd..83c66540 100644 --- a/src/WixToolset.Extensibility/Services/IParseHelper.cs +++ b/src/WixToolset.Extensibility/Services/IParseHelper.cs @@ -107,17 +107,6 @@ namespace WixToolset.Extensibility.Services /// If true, "escape" leading '#' characters so the value is written as a REG_SZ. Identifier CreateRegistrySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, RegistryRootType 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. - [Obsolete] - string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args); - /// /// Create a WixSimpleReference symbol in the active section. /// @@ -394,9 +383,9 @@ namespace WixToolset.Extensibility.Services /// Verifies if a filename is a valid short filename. /// /// Filename to verify. - /// true if wildcards are allowed in the filename. + /// Indicates whether wildcards are allowed in the filename. /// True if the filename is a valid short filename - bool IsValidShortFilename(string filename, bool allowWildcards = false); + bool IsValidShortFilename(string filename, bool allowWildcards); /// /// Attempts to use an extension to parse the attribute. diff --git a/src/WixToolset.Extensibility/Services/IPathResolver.cs b/src/WixToolset.Extensibility/Services/IPathResolver.cs index 5be0c4d3..64362174 100644 --- a/src/WixToolset.Extensibility/Services/IPathResolver.cs +++ b/src/WixToolset.Extensibility/Services/IPathResolver.cs @@ -6,9 +6,10 @@ namespace WixToolset.Extensibility.Services using WixToolset.Data; using WixToolset.Extensibility.Data; -#pragma warning disable 1591 // TODO: add documentation + /// + /// Support for processing paths. + /// public interface IPathResolver -#pragma warning restore 1591 { /// /// Get the canonical source path of a directory. diff --git a/src/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs b/src/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs index 80d49d54..81325131 100644 --- a/src/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs +++ b/src/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs @@ -17,7 +17,7 @@ namespace WixToolset.Extensibility.Services /// Symbol with line information for the row. /// Windows Installer data. /// Table definition for the row. - /// + /// Row created in the . Row CreateRow(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinition tableDefinition); /// diff --git a/src/WixToolset.Extensibility/Services/IWixBranding.cs b/src/WixToolset.Extensibility/Services/IWixBranding.cs new file mode 100644 index 00000000..4bac9ccd --- /dev/null +++ b/src/WixToolset.Extensibility/Services/IWixBranding.cs @@ -0,0 +1,26 @@ +// 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.Reflection; + + /// + /// WiX branding interface. + /// + public interface IWixBranding + { + /// + /// Gets the value for CreatingApplication field (MSI Summary Information Stream). + /// + /// String for creating application. + string GetCreatingApplication(); + + /// + /// Replaces branding placeholders in original string. + /// + /// Original string containing placeholders to replace. + /// Optional assembly with branding information, if not specified core branding is used. + /// + string ReplacePlaceholders(string original, Assembly assembly = null); + } +} -- cgit v1.2.3-55-g6feb