From 5392cf57c09bddde7157e5b26c5c2a013f819ead Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 1 Mar 2019 11:12:52 -0800 Subject: Integrate interface-only WixToolset.Extensibility change --- src/WixToolset.Core/Bind/FileResolver.cs | 12 +- src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | 2 +- src/WixToolset.Core/BindFileWithPath.cs | 22 ++ src/WixToolset.Core/BindPath.cs | 18 ++ src/WixToolset.Core/BindResult.cs | 14 ++ src/WixToolset.Core/Binder.cs | 4 +- src/WixToolset.Core/CommandLine/BuildCommand.cs | 275 +++++++++++---------- src/WixToolset.Core/CompilerCore.cs | 6 +- src/WixToolset.Core/ComponentKeyPath.cs | 24 ++ src/WixToolset.Core/DecompileResult.cs | 15 ++ src/WixToolset.Core/Decompiler.cs | 4 +- .../ExtensibilityServices/ParseHelper.cs | 6 +- src/WixToolset.Core/IBinder.cs | 4 +- src/WixToolset.Core/IDecompiler.cs | 2 +- src/WixToolset.Core/IResolver.cs | 4 +- src/WixToolset.Core/LibraryContext.cs | 4 +- src/WixToolset.Core/ResolveContext.cs | 4 +- src/WixToolset.Core/ResolveFileResult.cs | 14 ++ src/WixToolset.Core/ResolveResult.cs | 19 ++ src/WixToolset.Core/ResolvedCabinet.cs | 22 ++ src/WixToolset.Core/Resolver.cs | 4 +- src/WixToolset.Core/VariableResolution.cs | 29 +++ src/WixToolset.Core/VariableResolver.cs | 11 +- src/WixToolset.Core/WixToolsetServiceProvider.cs | 14 +- 24 files changed, 370 insertions(+), 163 deletions(-) create mode 100644 src/WixToolset.Core/BindFileWithPath.cs create mode 100644 src/WixToolset.Core/BindPath.cs create mode 100644 src/WixToolset.Core/BindResult.cs create mode 100644 src/WixToolset.Core/ComponentKeyPath.cs create mode 100644 src/WixToolset.Core/DecompileResult.cs create mode 100644 src/WixToolset.Core/ResolveFileResult.cs create mode 100644 src/WixToolset.Core/ResolveResult.cs create mode 100644 src/WixToolset.Core/ResolvedCabinet.cs create mode 100644 src/WixToolset.Core/VariableResolution.cs (limited to 'src/WixToolset.Core') diff --git a/src/WixToolset.Core/Bind/FileResolver.cs b/src/WixToolset.Core/Bind/FileResolver.cs index 01dfe36c..a67d784d 100644 --- a/src/WixToolset.Core/Bind/FileResolver.cs +++ b/src/WixToolset.Core/Bind/FileResolver.cs @@ -1,4 +1,4 @@ -// 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. +// 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.Core.Bind { @@ -14,24 +14,24 @@ namespace WixToolset.Core.Bind { private const string BindPathOpenString = "!(bindpath."; - private FileResolver(IEnumerable bindPaths) + private FileResolver(IEnumerable bindPaths) { - this.BindPaths = (bindPaths ?? Array.Empty()).ToLookup(b => b.Stage); + this.BindPaths = (bindPaths ?? Array.Empty()).ToLookup(b => b.Stage); this.RebaseTarget = this.BindPaths[BindStage.Target].Any(); this.RebaseUpdated = this.BindPaths[BindStage.Updated].Any(); } - public FileResolver(IEnumerable bindPaths, IEnumerable extensions) : this(bindPaths) + public FileResolver(IEnumerable bindPaths, IEnumerable extensions) : this(bindPaths) { this.ResolverExtensions = extensions ?? Array.Empty(); } - public FileResolver(IEnumerable bindPaths, IEnumerable extensions) : this(bindPaths) + public FileResolver(IEnumerable bindPaths, IEnumerable extensions) : this(bindPaths) { this.LibrarianExtensions = extensions ?? Array.Empty(); } - private ILookup BindPaths { get; } + private ILookup BindPaths { get; } public bool RebaseTarget { get; } diff --git a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs index b7ed8a18..6c9f17dd 100644 --- a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs +++ b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs @@ -20,7 +20,7 @@ namespace WixToolset.Core.Bind public IVariableResolver VariableResolver { private get; set; } - public IEnumerable BindPaths { private get; set; } + public IEnumerable BindPaths { private get; set; } public IEnumerable Extensions { private get; set; } diff --git a/src/WixToolset.Core/BindFileWithPath.cs b/src/WixToolset.Core/BindFileWithPath.cs new file mode 100644 index 00000000..539600d3 --- /dev/null +++ b/src/WixToolset.Core/BindFileWithPath.cs @@ -0,0 +1,22 @@ +// 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.Core +{ + using WixToolset.Extensibility.Data; + + /// + /// Bind file with its path. + /// + internal class BindFileWithPath : IBindFileWithPath + { + /// + /// Gets or sets the identifier of the file with this path. + /// + public string Id { get; set; } + + /// + /// Gets or sets the file path. + /// + public string Path { get; set; } + } +} diff --git a/src/WixToolset.Core/BindPath.cs b/src/WixToolset.Core/BindPath.cs new file mode 100644 index 00000000..85aef97a --- /dev/null +++ b/src/WixToolset.Core/BindPath.cs @@ -0,0 +1,18 @@ +// 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.Core +{ + using WixToolset.Extensibility.Data; + + /// + /// Bind path representation. + /// + internal class BindPath : IBindPath + { + public string Name { get; set; } + + public string Path { get; set; } + + public BindStage Stage { get; set; } + } +} diff --git a/src/WixToolset.Core/BindResult.cs b/src/WixToolset.Core/BindResult.cs new file mode 100644 index 00000000..7883fabd --- /dev/null +++ b/src/WixToolset.Core/BindResult.cs @@ -0,0 +1,14 @@ +// 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.Core +{ + using System.Collections.Generic; + using WixToolset.Extensibility.Data; + + internal class BindResult : IBindResult + { + public IEnumerable FileTransfers { get; set; } + + public IEnumerable TrackedFiles { get; set; } + } +} diff --git a/src/WixToolset.Core/Binder.cs b/src/WixToolset.Core/Binder.cs index 87b5d2b3..73ad7c04 100644 --- a/src/WixToolset.Core/Binder.cs +++ b/src/WixToolset.Core/Binder.cs @@ -24,7 +24,7 @@ namespace WixToolset.Core public IServiceProvider ServiceProvider { get; } - public BindResult Bind(IBindContext context) + public IBindResult Bind(IBindContext context) { // Prebind. // @@ -52,7 +52,7 @@ namespace WixToolset.Core return bindResult; } - private BindResult BackendBind(IBindContext context) + private IBindResult BackendBind(IBindContext context) { var extensionManager = context.ServiceProvider.GetService(); diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index fbc88f08..b83aaec4 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs @@ -21,7 +21,7 @@ namespace WixToolset.Core.CommandLine this.ServiceProvider = serviceProvider; this.Messaging = serviceProvider.GetService(); this.ExtensionManager = serviceProvider.GetService(); - this.commandLine = new CommandLine(this.Messaging); + this.commandLine = new CommandLine(this.ServiceProvider, this.Messaging); } public bool ShowLogo => this.commandLine.ShowLogo; @@ -214,7 +214,7 @@ namespace WixToolset.Core.CommandLine return intermediates; } - private Intermediate LibraryPhase(IEnumerable intermediates, IEnumerable localizations, bool bindFiles, IEnumerable bindPaths) + private Intermediate LibraryPhase(IEnumerable intermediates, IEnumerable localizations, bool bindFiles, IEnumerable bindPaths) { var context = this.ServiceProvider.GetService(); context.BindFiles = bindFiles; @@ -257,7 +257,7 @@ namespace WixToolset.Core.CommandLine return linker.Link(context); } - private void BindPhase(Intermediate output, IEnumerable localizations, IEnumerable filterCultures, string cabCachePath, IEnumerable bindPaths) + private void BindPhase(Intermediate output, IEnumerable localizations, IEnumerable filterCultures, string cabCachePath, IEnumerable bindPaths) { var intermediateFolder = this.IntermediateFolder; if (String.IsNullOrEmpty(intermediateFolder)) @@ -265,7 +265,7 @@ namespace WixToolset.Core.CommandLine intermediateFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } - ResolveResult resolveResult; + IResolveResult resolveResult; { var context = this.ServiceProvider.GetService(); context.BindPaths = bindPaths; @@ -286,7 +286,7 @@ namespace WixToolset.Core.CommandLine return; } - BindResult bindResult; + IBindResult bindResult; { var context = this.ServiceProvider.GetService(); //context.CabbingThreadCount = this.CabbingThreadCount; @@ -397,7 +397,7 @@ namespace WixToolset.Core.CommandLine public bool BindFiles { get; private set; } - public List BindPaths { get; } = new List(); + public List BindPaths { get; } = new List(); public string CabCachePath { get; private set; } @@ -431,11 +431,14 @@ namespace WixToolset.Core.CommandLine public string BuiltOutputsFile { get; private set; } - public CommandLine(IMessaging messaging) + public CommandLine(IServiceProvider serviceProvider, IMessaging messaging) { + this.ServiceProvider = serviceProvider; this.Messaging = messaging; } + private IServiceProvider ServiceProvider { get; } + private IMessaging Messaging { get; } public bool TryParseArgument(string arg, ICommandLineParser parser) @@ -445,109 +448,109 @@ namespace WixToolset.Core.CommandLine var parameter = arg.Substring(1); switch (parameter.ToLowerInvariant()) { - case "?": - case "h": - case "help": - this.ShowHelp = true; - return true; - - case "arch": - case "platform": - { - var value = parser.GetNextArgumentOrError(arg); - if (Enum.TryParse(value, true, out Platform platform)) - { - this.Platform = platform; + case "?": + case "h": + case "help": + this.ShowHelp = true; return true; - } - break; - } - - case "bindfiles": - this.BindFiles = true; - return true; - case "bindpath": - { - var value = parser.GetNextArgumentOrError(arg); - if (this.TryParseBindPath(value, out var bindPath)) + case "arch": + case "platform": { - this.BindPaths.Add(bindPath); - return true; + var value = parser.GetNextArgumentOrError(arg); + if (Enum.TryParse(value, true, out Platform platform)) + { + this.Platform = platform; + return true; + } + break; } - break; - } - case "cc": - this.CabCachePath = parser.GetNextArgumentOrError(arg); - return true; - - case "culture": - parser.GetNextArgumentOrError(arg, this.Cultures); - return true; - - case "contentsfile": - this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg); - return true; - case "outputsfile": - this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); - return true; - case "builtoutputsfile": - this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); - return true; - - case "d": - case "define": - parser.GetNextArgumentOrError(arg, this.Defines); - return true; - - case "i": - case "includepath": - parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths); - return true; - - case "intermediatefolder": - this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); - return true; - - case "loc": - parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths); - return true; - - case "lib": - parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths); - return true; - - case "o": - case "out": - this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); - return true; - - case "outputtype": - this.OutputType = parser.GetNextArgumentOrError(arg); - return true; - - case "nologo": - this.ShowLogo = false; - return true; - - case "v": - case "verbose": - this.Messaging.ShowVerboseMessages = true; - return true; - - case "sval": - // todo: implement - return true; - - case "sw": - case "suppresswarning": - var warning = parser.GetNextArgumentOrError(arg); - if (!String.IsNullOrEmpty(warning)) + + case "bindfiles": + this.BindFiles = true; + return true; + + case "bindpath": { - var warningNumber = Convert.ToInt32(warning); - this.Messaging.SuppressWarningMessage(warningNumber); + var value = parser.GetNextArgumentOrError(arg); + if (this.TryParseBindPath(value, out var bindPath)) + { + this.BindPaths.Add(bindPath); + return true; + } + break; } - return true; + case "cc": + this.CabCachePath = parser.GetNextArgumentOrError(arg); + return true; + + case "culture": + parser.GetNextArgumentOrError(arg, this.Cultures); + return true; + + case "contentsfile": + this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg); + return true; + case "outputsfile": + this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); + return true; + case "builtoutputsfile": + this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); + return true; + + case "d": + case "define": + parser.GetNextArgumentOrError(arg, this.Defines); + return true; + + case "i": + case "includepath": + parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths); + return true; + + case "intermediatefolder": + this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); + return true; + + case "loc": + parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths); + return true; + + case "lib": + parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths); + return true; + + case "o": + case "out": + this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); + return true; + + case "outputtype": + this.OutputType = parser.GetNextArgumentOrError(arg); + return true; + + case "nologo": + this.ShowLogo = false; + return true; + + case "v": + case "verbose": + this.Messaging.ShowVerboseMessages = true; + return true; + + case "sval": + // todo: implement + return true; + + case "sw": + case "suppresswarning": + var warning = parser.GetNextArgumentOrError(arg); + if (!String.IsNullOrEmpty(warning)) + { + var warningNumber = Convert.ToInt32(warning); + this.Messaging.SuppressWarningMessage(warningNumber); + } + return true; } return false; @@ -573,37 +576,37 @@ namespace WixToolset.Core.CommandLine switch (this.OutputType.ToLowerInvariant()) { - case "bundle": - case ".exe": - return Data.OutputType.Bundle; + case "bundle": + case ".exe": + return Data.OutputType.Bundle; - case "library": - case ".wixlib": - return Data.OutputType.Library; + case "library": + case ".wixlib": + return Data.OutputType.Library; - case "module": - case ".msm": - return Data.OutputType.Module; + case "module": + case ".msm": + return Data.OutputType.Module; - case "patch": - case ".msp": - return Data.OutputType.Patch; + case "patch": + case ".msp": + return Data.OutputType.Patch; - case ".pcp": - return Data.OutputType.PatchCreation; + case ".pcp": + return Data.OutputType.PatchCreation; - case "product": - case "package": - case ".msi": - return Data.OutputType.Product; + case "product": + case "package": + case ".msi": + return Data.OutputType.Product; - case "transform": - case ".mst": - return Data.OutputType.Transform; + case "transform": + case ".mst": + return Data.OutputType.Transform; - case "intermediatepostlink": - case ".wixipl": - return Data.OutputType.IntermediatePostLink; + case "intermediatepostlink": + case ".wixipl": + return Data.OutputType.IntermediatePostLink; } return Data.OutputType.Unknown; @@ -656,7 +659,6 @@ namespace WixToolset.Core.CommandLine return variables; } - public IEnumerable GatherSourceFiles(string intermediateDirectory) { var files = new List(); @@ -672,10 +674,21 @@ namespace WixToolset.Core.CommandLine return files; } - private bool TryParseBindPath(string bindPath, out BindPath bp) + private bool TryParseBindPath(string bindPath, out IBindPath bp) { var namedPath = bindPath.Split(BindPathSplit, 2); - bp = (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]); + + bp = this.ServiceProvider.GetService(); + + if (1 == namedPath.Length) + { + bp.Path = namedPath[0]; + } + else + { + bp.Name = namedPath[0]; + bp.Path = namedPath[1]; + } if (File.Exists(bp.Path)) { diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs index cc881f48..4df94713 100644 --- a/src/WixToolset.Core/CompilerCore.cs +++ b/src/WixToolset.Core/CompilerCore.cs @@ -534,7 +534,7 @@ namespace WixToolset.Core string value = this.GetAttributeValue(sourceLineNumbers, attribute); // allow for localization of code page names and values - if (IsValidLocIdentifier(value)) + if (this.IsValidLocIdentifier(value)) { return value; } @@ -648,7 +648,7 @@ namespace WixToolset.Core if (0 < value.Length) { - if (IsValidLocIdentifier(value) || Common.IsValidBinderVariable(value)) + if (this.IsValidLocIdentifier(value) || Common.IsValidBinderVariable(value)) { return value; } @@ -1010,7 +1010,7 @@ namespace WixToolset.Core /// Element containing element to be parsed. /// Element to be parsed. /// Extra information about the context in which this element is being parsed. - public ComponentKeyPath ParsePossibleKeyPathExtensionElement(XElement parentElement, XElement element, IDictionary context) + public IComponentKeyPath ParsePossibleKeyPathExtensionElement(XElement parentElement, XElement element, IDictionary context) { return this.parseHelper.ParsePossibleKeyPathExtensionElement(this.extensions.Values, this.intermediate, this.ActiveSection, parentElement, element, context); } diff --git a/src/WixToolset.Core/ComponentKeyPath.cs b/src/WixToolset.Core/ComponentKeyPath.cs new file mode 100644 index 00000000..f81465fd --- /dev/null +++ b/src/WixToolset.Core/ComponentKeyPath.cs @@ -0,0 +1,24 @@ +// 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.Core +{ + using WixToolset.Extensibility.Data; + + internal class ComponentKeyPath : IComponentKeyPath + { + /// + /// Identifier of the resource to be a key path. + /// + public string Id { get; set; } + + /// + /// Indicates whether the key path was explicitly set for this resource. + /// + public bool Explicit { get; set; } + + /// + /// Type of resource to be the key path. + /// + public ComponentKeyPathType Type { get; set; } + } +} diff --git a/src/WixToolset.Core/DecompileResult.cs b/src/WixToolset.Core/DecompileResult.cs new file mode 100644 index 00000000..120d099d --- /dev/null +++ b/src/WixToolset.Core/DecompileResult.cs @@ -0,0 +1,15 @@ +// 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.Core +{ + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Extensibility.Data; + + internal class DecompileResult : IDecompileResult + { + public XDocument Document { get; set; } + + public IEnumerable ExtractedFilePaths { get; set; } + } +} diff --git a/src/WixToolset.Core/Decompiler.cs b/src/WixToolset.Core/Decompiler.cs index 685722a8..c0ca200b 100644 --- a/src/WixToolset.Core/Decompiler.cs +++ b/src/WixToolset.Core/Decompiler.cs @@ -19,7 +19,7 @@ namespace WixToolset.Core public IServiceProvider ServiceProvider { get; } - public DecompileResult Decompile(IDecompileContext context) + public IDecompileResult Decompile(IDecompileContext context) { // Pre-decompile. // @@ -45,7 +45,7 @@ namespace WixToolset.Core return result; } - private DecompileResult BackendDecompile(IDecompileContext context) + private IDecompileResult BackendDecompile(IDecompileContext context) { var extensionManager = context.ServiceProvider.GetService(); diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index f62f8f10..dce77781 100644 --- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs @@ -1,4 +1,4 @@ -// 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. +// 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.Core.ExtensibilityServices { @@ -777,9 +777,9 @@ namespace WixToolset.Core.ExtensibilityServices } } - public ComponentKeyPath ParsePossibleKeyPathExtensionElement(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + public IComponentKeyPath ParsePossibleKeyPathExtensionElement(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { - ComponentKeyPath keyPath = null; + IComponentKeyPath keyPath = null; if (ParseHelper.TryFindExtension(extensions, element.Name.Namespace, out var extension)) { diff --git a/src/WixToolset.Core/IBinder.cs b/src/WixToolset.Core/IBinder.cs index 884ee6b9..c2ebc2a0 100644 --- a/src/WixToolset.Core/IBinder.cs +++ b/src/WixToolset.Core/IBinder.cs @@ -1,4 +1,4 @@ -// 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. +// 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.Core { @@ -6,6 +6,6 @@ namespace WixToolset.Core public interface IBinder { - BindResult Bind(IBindContext context); + IBindResult Bind(IBindContext context); } } diff --git a/src/WixToolset.Core/IDecompiler.cs b/src/WixToolset.Core/IDecompiler.cs index 82b02943..05b04be2 100644 --- a/src/WixToolset.Core/IDecompiler.cs +++ b/src/WixToolset.Core/IDecompiler.cs @@ -6,6 +6,6 @@ namespace WixToolset.Core public interface IDecompiler { - DecompileResult Decompile(IDecompileContext context); + IDecompileResult Decompile(IDecompileContext context); } } diff --git a/src/WixToolset.Core/IResolver.cs b/src/WixToolset.Core/IResolver.cs index a027f348..c5b2568f 100644 --- a/src/WixToolset.Core/IResolver.cs +++ b/src/WixToolset.Core/IResolver.cs @@ -1,4 +1,4 @@ -// 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. +// 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.Core { @@ -6,6 +6,6 @@ namespace WixToolset.Core public interface IResolver { - ResolveResult Resolve(IResolveContext context); + IResolveResult Resolve(IResolveContext context); } } diff --git a/src/WixToolset.Core/LibraryContext.cs b/src/WixToolset.Core/LibraryContext.cs index e61b6ce8..5dd17dc8 100644 --- a/src/WixToolset.Core/LibraryContext.cs +++ b/src/WixToolset.Core/LibraryContext.cs @@ -1,4 +1,4 @@ -// 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. +// 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.Core { @@ -22,7 +22,7 @@ namespace WixToolset.Core public bool BindFiles { get; set; } - public IEnumerable BindPaths { get; set; } + public IEnumerable BindPaths { get; set; } public IEnumerable Extensions { get; set; } diff --git a/src/WixToolset.Core/ResolveContext.cs b/src/WixToolset.Core/ResolveContext.cs index cadc6678..1801f820 100644 --- a/src/WixToolset.Core/ResolveContext.cs +++ b/src/WixToolset.Core/ResolveContext.cs @@ -1,4 +1,4 @@ -// 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. +// 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.Core { @@ -18,7 +18,7 @@ namespace WixToolset.Core public IServiceProvider ServiceProvider { get; } - public IEnumerable BindPaths { get; set; } + public IEnumerable BindPaths { get; set; } public IEnumerable Extensions { get; set; } diff --git a/src/WixToolset.Core/ResolveFileResult.cs b/src/WixToolset.Core/ResolveFileResult.cs new file mode 100644 index 00000000..e36c474a --- /dev/null +++ b/src/WixToolset.Core/ResolveFileResult.cs @@ -0,0 +1,14 @@ +// 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.Core +{ + using System.Collections.Generic; + using WixToolset.Extensibility.Data; + + public class ResolveFileResult : IResolveFileResult + { + public string Path { get; set; } + + public IEnumerable CheckedPaths { get; set; } + } +} diff --git a/src/WixToolset.Core/ResolveResult.cs b/src/WixToolset.Core/ResolveResult.cs new file mode 100644 index 00000000..6b6bc7c4 --- /dev/null +++ b/src/WixToolset.Core/ResolveResult.cs @@ -0,0 +1,19 @@ +// 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.Core +{ + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Extensibility.Data; + + internal class ResolveResult : IResolveResult + { + public int Codepage { get; set; } + + public IEnumerable DelayedFields { get; set; } + + public IEnumerable ExpectedEmbeddedFiles { get; set; } + + public Intermediate IntermediateRepresentation { get; set; } + } +} diff --git a/src/WixToolset.Core/ResolvedCabinet.cs b/src/WixToolset.Core/ResolvedCabinet.cs new file mode 100644 index 00000000..9304b413 --- /dev/null +++ b/src/WixToolset.Core/ResolvedCabinet.cs @@ -0,0 +1,22 @@ +// 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.Core +{ + using WixToolset.Extensibility.Data; + + /// + /// Data returned from build file manager ResolveCabinet callback. + /// + public class ResolvedCabinet : IResolvedCabinet + { + /// + /// Gets or sets the build option for the resolved cabinet. + /// + public CabinetBuildOption BuildOption { get; set; } + + /// + /// Gets or sets the path for the resolved cabinet. + /// + public string Path { get; set; } + } +} diff --git a/src/WixToolset.Core/Resolver.cs b/src/WixToolset.Core/Resolver.cs index 98101f16..c69c4f68 100644 --- a/src/WixToolset.Core/Resolver.cs +++ b/src/WixToolset.Core/Resolver.cs @@ -28,7 +28,7 @@ namespace WixToolset.Core private IMessaging Messaging { get; } - public IEnumerable BindPaths { get; set; } + public IEnumerable BindPaths { get; set; } public string IntermediateFolder { get; set; } @@ -38,7 +38,7 @@ namespace WixToolset.Core public IEnumerable FilterCultures { get; set; } - public ResolveResult Resolve(IResolveContext context) + public IResolveResult Resolve(IResolveContext context) { foreach (var extension in context.Extensions) diff --git a/src/WixToolset.Core/VariableResolution.cs b/src/WixToolset.Core/VariableResolution.cs new file mode 100644 index 00000000..3b34e294 --- /dev/null +++ b/src/WixToolset.Core/VariableResolution.cs @@ -0,0 +1,29 @@ +// 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.Core +{ + using WixToolset.Extensibility.Services; + + internal class VariableResolution : IVariableResolution + { + /// + /// Indicates whether the variable should be delay resolved. + /// + public bool DelayedResolve { get; set; } + + /// + /// Indicates whether the value is the default value of the variable. + /// + public bool IsDefault { get; set; } + + /// + /// Indicates whether the value changed. + /// + public bool UpdatedValue { get; set; } + + /// + /// Resolved value. + /// + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/WixToolset.Core/VariableResolver.cs b/src/WixToolset.Core/VariableResolver.cs index eb65d3d6..de722613 100644 --- a/src/WixToolset.Core/VariableResolver.cs +++ b/src/WixToolset.Core/VariableResolver.cs @@ -23,6 +23,7 @@ namespace WixToolset.Core /// internal VariableResolver(IServiceProvider serviceProvider) { + this.ServiceProvider = serviceProvider; this.Messaging = serviceProvider.GetService(); this.locVariables = new Dictionary(); @@ -31,6 +32,8 @@ namespace WixToolset.Core this.Codepage = -1; } + private IServiceProvider ServiceProvider { get; } + private IMessaging Messaging { get; } public int Codepage { get; private set; } @@ -71,7 +74,7 @@ namespace WixToolset.Core } } - public VariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly) + public IVariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly) { return this.ResolveVariables(sourceLineNumbers, value, localizationOnly, true); } @@ -90,12 +93,14 @@ namespace WixToolset.Core /// true to only resolve localization variables; false otherwise. /// true if unknown variables should throw errors. /// The resolved value. - internal VariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, bool errorOnUnknown) + internal IVariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, bool errorOnUnknown) { var matches = Common.WixVariableRegex.Matches(value); // the value is the default unless its substituted further down - var result = new VariableResolution { IsDefault = true, Value = value }; + var result = this.ServiceProvider.GetService(); + result.IsDefault = true; + result.Value = value; if (0 < matches.Count) { diff --git a/src/WixToolset.Core/WixToolsetServiceProvider.cs b/src/WixToolset.Core/WixToolsetServiceProvider.cs index 49d4b3fe..d29d4e3f 100644 --- a/src/WixToolset.Core/WixToolsetServiceProvider.cs +++ b/src/WixToolset.Core/WixToolsetServiceProvider.cs @@ -40,6 +40,15 @@ namespace WixToolset.Core this.AddService((provider, singletons) => new LayoutContext(provider)); this.AddService((provider, singletons) => new InscribeContext(provider)); + this.AddService((provider, singletons) => new BindFileWithPath()); + this.AddService((provider, singletons) => new BindPath()); + this.AddService((provider, singletons) => new BindResult()); + this.AddService((provider, singletons) => new ComponentKeyPath()); + this.AddService((provider, singletons) => new DecompileResult()); + this.AddService((provider, singletons) => new ResolveResult()); + this.AddService((provider, singletons) => new ResolvedCabinet()); + this.AddService((provider, singletons) => new VariableResolution()); + this.AddService((provider, singletons) => new Binder(provider)); this.AddService((provider, singletons) => new Compiler(provider)); this.AddService((provider, singletons) => new Decompiler(provider)); @@ -59,7 +68,10 @@ namespace WixToolset.Core public bool TryGetService(Type serviceType, out object service) { - if (serviceType == null) throw new ArgumentNullException(nameof(serviceType)); + if (serviceType == null) + { + throw new ArgumentNullException(nameof(serviceType)); + } if (!this.Singletons.TryGetValue(serviceType, out service)) { -- cgit v1.2.3-55-g6feb