From 52005c7e6917f9866dd0b0de6993def16a72ed4b Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Aug 2018 03:02:34 -0700 Subject: Major reduction in public surface area of WixToolset.Core --- src/WixToolset.Core/Bind/FileFacade.cs | 8 +- src/WixToolset.Core/BindContext.cs | 2 +- src/WixToolset.Core/Binder.cs | 4 +- src/WixToolset.Core/CommandLine/BuildCommand.cs | 5 +- .../CommandLine/CommandLineResponseFile.cs | 132 --------------------- src/WixToolset.Core/CompileContext.cs | 2 +- src/WixToolset.Core/Compiler.cs | 4 +- src/WixToolset.Core/CompilerCore.cs | 2 +- src/WixToolset.Core/Converter.cs | 4 +- src/WixToolset.Core/Harvester.cs | 2 +- src/WixToolset.Core/HarvesterCore.cs | 2 +- src/WixToolset.Core/HeatCore.cs | 2 +- src/WixToolset.Core/ILocalizer.cs | 27 +++++ src/WixToolset.Core/Inscriber.cs | 4 +- src/WixToolset.Core/Layout.cs | 4 +- src/WixToolset.Core/LayoutContext.cs | 2 +- src/WixToolset.Core/Librarian.cs | 4 +- src/WixToolset.Core/LibraryContext.cs | 4 +- src/WixToolset.Core/Link/ConnectToFeature.cs | 4 +- .../Link/ConnectToFeatureCollection.cs | 4 +- src/WixToolset.Core/Link/ConnectToModule.cs | 4 +- .../Link/ConnectToModuleCollection.cs | 4 +- .../Link/ReportConflictingSymbolsCommand.cs | 4 +- .../Link/ResolveReferencesCommand.cs | 2 +- src/WixToolset.Core/Link/WixGroupingOrdering.cs | 4 +- src/WixToolset.Core/LinkContext.cs | 2 +- src/WixToolset.Core/Linker.cs | 5 +- src/WixToolset.Core/Localizer.cs | 36 +++--- src/WixToolset.Core/Mutator.cs | 2 +- src/WixToolset.Core/OptimizeCA.cs | 2 +- src/WixToolset.Core/Preprocess/IfContext.cs | 2 +- .../Preprocess/ProcessedStreamEventHandler.cs | 4 +- src/WixToolset.Core/Preprocessor.cs | 16 +-- src/WixToolset.Core/ResolveContext.cs | 2 +- src/WixToolset.Core/Resolver.cs | 6 +- src/WixToolset.Core/SourceFile.cs | 6 +- src/WixToolset.Core/WixToolsetServiceProvider.cs | 5 +- src/WixToolset.Core/WixVariableResolver.cs | 2 +- 38 files changed, 110 insertions(+), 220 deletions(-) delete mode 100644 src/WixToolset.Core/CommandLine/CommandLineResponseFile.cs create mode 100644 src/WixToolset.Core/ILocalizer.cs (limited to 'src/WixToolset.Core') diff --git a/src/WixToolset.Core/Bind/FileFacade.cs b/src/WixToolset.Core/Bind/FileFacade.cs index ebca9cff..825c2c7a 100644 --- a/src/WixToolset.Core/Bind/FileFacade.cs +++ b/src/WixToolset.Core/Bind/FileFacade.cs @@ -21,13 +21,13 @@ namespace WixToolset.Core.Bind this.WixFile = wixFile; } - public bool FromModule { get; private set; } + public bool FromModule { get; } - public FileTuple File { get; private set; } + public FileTuple File { get; } - public WixFileTuple WixFile { get; private set; } + public WixFileTuple WixFile { get; } - public WixDeltaPatchFileTuple DeltaPatchFile { get; private set; } + public WixDeltaPatchFileTuple DeltaPatchFile { get; } /// /// Gets the set of MsiAssemblyName rows created for this file. diff --git a/src/WixToolset.Core/BindContext.cs b/src/WixToolset.Core/BindContext.cs index 12719f51..413be301 100644 --- a/src/WixToolset.Core/BindContext.cs +++ b/src/WixToolset.Core/BindContext.cs @@ -8,7 +8,7 @@ namespace WixToolset.Core using WixToolset.Extensibility; using WixToolset.Extensibility.Data; - public class BindContext : IBindContext + internal class BindContext : IBindContext { internal BindContext(IServiceProvider serviceProvider) { diff --git a/src/WixToolset.Core/Binder.cs b/src/WixToolset.Core/Binder.cs index 2a40ce71..bbc4173b 100644 --- a/src/WixToolset.Core/Binder.cs +++ b/src/WixToolset.Core/Binder.cs @@ -16,9 +16,9 @@ namespace WixToolset.Core /// /// Binder of the WiX toolset. /// - public sealed class Binder + internal class Binder { - public Binder(IServiceProvider serviceProvider) + internal Binder(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; } diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 822c4a9a..5c089b5f 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs @@ -317,6 +317,8 @@ namespace WixToolset.Core.CommandLine private IEnumerable LoadLocalizationFiles() { + var localizer = new Localizer(this.ServiceProvider); + foreach (var loc in this.LocFiles) { var preprocessor = new Preprocessor(this.ServiceProvider); @@ -331,8 +333,7 @@ namespace WixToolset.Core.CommandLine continue; } - var localization = Localizer.ParseLocalizationFile(this.Messaging, document); - + var localization = localizer.ParseLocalizationFile(document); yield return localization; } } diff --git a/src/WixToolset.Core/CommandLine/CommandLineResponseFile.cs b/src/WixToolset.Core/CommandLine/CommandLineResponseFile.cs deleted file mode 100644 index 6922b246..00000000 --- a/src/WixToolset.Core/CommandLine/CommandLineResponseFile.cs +++ /dev/null @@ -1,132 +0,0 @@ -// 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.CommandLine -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Text; - using System.Text.RegularExpressions; - - /// - /// Common utilities for Wix command-line processing. - /// - public static class CommandLineResponseFile - { - /// - /// Parses a response file. - /// - /// The file to parse. - /// The array of arguments. - public static string[] Parse(string responseFile) - { - string arguments; - - using (StreamReader reader = new StreamReader(responseFile)) - { - arguments = reader.ReadToEnd(); - } - - return CommandLineResponseFile.ParseArgumentsToArray(arguments); - } - - /// - /// Parses an argument string into an argument array based on whitespace and quoting. - /// - /// Argument string. - /// Argument array. - public static string[] ParseArgumentsToArray(string arguments) - { - // Scan and parse the arguments string, dividing up the arguments based on whitespace. - // Unescaped quotes cause whitespace to be ignored, while the quotes themselves are removed. - // Quotes may begin and end inside arguments; they don't necessarily just surround whole arguments. - // Escaped quotes and escaped backslashes also need to be unescaped by this process. - - // Collects the final list of arguments to be returned. - List argsList = new List(); - - // True if we are inside an unescaped quote, meaning whitespace should be ignored. - bool insideQuote = false; - - // Index of the start of the current argument substring; either the start of the argument - // or the start of a quoted or unquoted sequence within it. - int partStart = 0; - - // The current argument string being built; when completed it will be added to the list. - StringBuilder arg = new StringBuilder(); - - for (int i = 0; i <= arguments.Length; i++) - { - if (i == arguments.Length || (Char.IsWhiteSpace(arguments[i]) && !insideQuote)) - { - // Reached a whitespace separator or the end of the string. - - // Finish building the current argument. - arg.Append(arguments.Substring(partStart, i - partStart)); - - // Skip over the whitespace character. - partStart = i + 1; - - // Add the argument to the list if it's not empty. - if (arg.Length > 0) - { - argsList.Add(CommandLineResponseFile.ExpandEnvVars(arg.ToString())); - arg.Length = 0; - } - } - else if (i > partStart && arguments[i - 1] == '\\') - { - // Check the character following an unprocessed backslash. - // Unescape quotes, and backslashes followed by a quote. - if (arguments[i] == '"' || (arguments[i] == '\\' && arguments.Length > i + 1 && arguments[i + 1] == '"')) - { - // Unescape the quote or backslash by skipping the preceeding backslash. - arg.Append(arguments.Substring(partStart, i - 1 - partStart)); - arg.Append(arguments[i]); - partStart = i + 1; - } - } - else if (arguments[i] == '"') - { - // Add the quoted or unquoted section to the argument string. - arg.Append(arguments.Substring(partStart, i - partStart)); - - // And skip over the quote character. - partStart = i + 1; - - insideQuote = !insideQuote; - } - } - - return argsList.ToArray(); - } - - static private string ExpandEnvVars(string arguments) - { - IDictionary id = Environment.GetEnvironmentVariables(); - - Regex regex = new Regex("(?<=\\%)(?:[\\w\\.]+)(?=\\%)"); - MatchCollection matches = regex.Matches(arguments); - - string value = String.Empty; - for (int i = 0; i <= (matches.Count - 1); i++) - { - try - { - string key = matches[i].Value; - regex = new Regex(String.Concat("(?i)(?:\\%)(?:" , key , ")(?:\\%)")); - value = id[key].ToString(); - arguments = regex.Replace(arguments, value); - } - catch (NullReferenceException) - { - // Collapse unresolved environment variables. - arguments = regex.Replace(arguments, value); - } - } - - return arguments; - } - } -} diff --git a/src/WixToolset.Core/CompileContext.cs b/src/WixToolset.Core/CompileContext.cs index 6f19961f..c7a0905e 100644 --- a/src/WixToolset.Core/CompileContext.cs +++ b/src/WixToolset.Core/CompileContext.cs @@ -9,7 +9,7 @@ namespace WixToolset.Core using WixToolset.Extensibility; using WixToolset.Extensibility.Data; - public class CompileContext : ICompileContext + internal class CompileContext : ICompileContext { internal CompileContext(IServiceProvider serviceProvider) { diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index 06f477c1..437c1481 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -22,7 +22,7 @@ namespace WixToolset.Core /// /// Compiler of the WiX toolset. /// - public sealed class Compiler + internal class Compiler { public const string UpgradeDetectedProperty = "WIX_UPGRADE_DETECTED"; public const string UpgradePreventedCondition = "NOT WIX_UPGRADE_DETECTED"; @@ -69,7 +69,7 @@ namespace WixToolset.Core Icon, } - public Compiler(IServiceProvider serviceProvider) + internal Compiler(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs index c9165b52..cc881f48 100644 --- a/src/WixToolset.Core/CompilerCore.cs +++ b/src/WixToolset.Core/CompilerCore.cs @@ -39,7 +39,7 @@ namespace WixToolset.Core /// /// Core class for the compiler. /// - internal sealed class CompilerCore + internal class CompilerCore { internal static readonly XNamespace W3SchemaPrefix = "http://www.w3.org/"; internal static readonly XNamespace WixNamespace = "http://wixtoolset.org/schemas/v4/wxs"; diff --git a/src/WixToolset.Core/Converter.cs b/src/WixToolset.Core/Converter.cs index fd925f7a..1f83c88f 100644 --- a/src/WixToolset.Core/Converter.cs +++ b/src/WixToolset.Core/Converter.cs @@ -15,7 +15,7 @@ namespace WixToolset.Core /// /// WiX source code converter. /// - public class Converter + internal class Converter { private const string XDocumentNewLine = "\n"; // XDocument normlizes "\r\n" to just "\n". private static readonly XNamespace WixNamespace = "http://wixtoolset.org/schemas/v4/wxs"; @@ -65,7 +65,7 @@ namespace WixToolset.Core /// Indentation value to use when validating leading whitespace. /// Test errors to display as warnings. /// Test errors to ignore. - public Converter(IMessaging messaging, int indentationAmount, IEnumerable errorsAsWarnings = null, IEnumerable ignoreErrors = null) + internal Converter(IMessaging messaging, int indentationAmount, IEnumerable errorsAsWarnings = null, IEnumerable ignoreErrors = null) { this.ConvertElementMapping = new Dictionary>() { diff --git a/src/WixToolset.Core/Harvester.cs b/src/WixToolset.Core/Harvester.cs index b9c27418..55d56e64 100644 --- a/src/WixToolset.Core/Harvester.cs +++ b/src/WixToolset.Core/Harvester.cs @@ -11,7 +11,7 @@ namespace WixToolset /// /// The WiX Toolset harvester. /// - public sealed class Harvester + public class Harvester { private HarvesterExtension harvesterExtension; diff --git a/src/WixToolset.Core/HarvesterCore.cs b/src/WixToolset.Core/HarvesterCore.cs index 92a057d8..70991979 100644 --- a/src/WixToolset.Core/HarvesterCore.cs +++ b/src/WixToolset.Core/HarvesterCore.cs @@ -10,7 +10,7 @@ namespace WixToolset.Core /// /// The WiX Toolset harvester core. /// - public sealed class HarvesterCore : IHarvesterCore + public class HarvesterCore : IHarvesterCore { public IMessaging Messaging { get; set; } diff --git a/src/WixToolset.Core/HeatCore.cs b/src/WixToolset.Core/HeatCore.cs index 8e02a7b5..d43b5f3d 100644 --- a/src/WixToolset.Core/HeatCore.cs +++ b/src/WixToolset.Core/HeatCore.cs @@ -7,7 +7,7 @@ namespace WixToolset.Core /// /// The WiX Toolset Harvester application core. /// - public sealed class HeatCore : IHeatCore + public class HeatCore : IHeatCore { private Harvester harvester; private Mutator mutator; diff --git a/src/WixToolset.Core/ILocalizer.cs b/src/WixToolset.Core/ILocalizer.cs new file mode 100644 index 00000000..f15d9ba7 --- /dev/null +++ b/src/WixToolset.Core/ILocalizer.cs @@ -0,0 +1,27 @@ +// 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.Xml.Linq; + using WixToolset.Data; + + /// + /// Parses localization files and localizes database values. + /// + public interface ILocalizer + { + /// + /// Loads a localization file from a path on disk. + /// + /// Path to localization file saved on disk. + /// Returns the loaded localization file. + Localization ParseLocalizationFile(string path); + + /// + /// Loads a localization file from memory. + /// + /// Document to parse as localization file. + /// Returns the loaded localization file. + Localization ParseLocalizationFile(XDocument document); + } +} diff --git a/src/WixToolset.Core/Inscriber.cs b/src/WixToolset.Core/Inscriber.cs index efe64ad2..649e1661 100644 --- a/src/WixToolset.Core/Inscriber.cs +++ b/src/WixToolset.Core/Inscriber.cs @@ -1,6 +1,6 @@ // 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 +namespace WixToolset.Core { using System.IO; using WixToolset.Data; @@ -8,7 +8,7 @@ namespace WixToolset /// /// Converts a wixout representation of an MSM database into a ComponentGroup the form of WiX source. /// - public sealed class Inscriber + internal class Inscriber { /// /// Gets or sets the temp files collection. diff --git a/src/WixToolset.Core/Layout.cs b/src/WixToolset.Core/Layout.cs index 28c9d5fc..128efc61 100644 --- a/src/WixToolset.Core/Layout.cs +++ b/src/WixToolset.Core/Layout.cs @@ -15,9 +15,9 @@ namespace WixToolset.Core /// /// Layout for the WiX toolset. /// - public sealed class Layout + internal class Layout { - public Layout(IServiceProvider serviceProvider) + internal Layout(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; diff --git a/src/WixToolset.Core/LayoutContext.cs b/src/WixToolset.Core/LayoutContext.cs index 172cea65..99ca611a 100644 --- a/src/WixToolset.Core/LayoutContext.cs +++ b/src/WixToolset.Core/LayoutContext.cs @@ -7,7 +7,7 @@ namespace WixToolset.Core using WixToolset.Extensibility; using WixToolset.Extensibility.Data; - public class LayoutContext : ILayoutContext + internal class LayoutContext : ILayoutContext { internal LayoutContext(IServiceProvider serviceProvider) { diff --git a/src/WixToolset.Core/Librarian.cs b/src/WixToolset.Core/Librarian.cs index 15efcfcc..abd6c844 100644 --- a/src/WixToolset.Core/Librarian.cs +++ b/src/WixToolset.Core/Librarian.cs @@ -15,9 +15,9 @@ namespace WixToolset.Core /// /// Core librarian tool. /// - public sealed class Librarian + internal class Librarian { - public Librarian(IServiceProvider serviceProvider) + internal Librarian(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; diff --git a/src/WixToolset.Core/LibraryContext.cs b/src/WixToolset.Core/LibraryContext.cs index 0b09aa93..e61b6ce8 100644 --- a/src/WixToolset.Core/LibraryContext.cs +++ b/src/WixToolset.Core/LibraryContext.cs @@ -9,9 +9,9 @@ namespace WixToolset.Core using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; - public class LibraryContext : ILibraryContext + internal class LibraryContext : ILibraryContext { - public LibraryContext(IServiceProvider serviceProvider) + internal LibraryContext(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; } diff --git a/src/WixToolset.Core/Link/ConnectToFeature.cs b/src/WixToolset.Core/Link/ConnectToFeature.cs index bc85426a..dd95f2db 100644 --- a/src/WixToolset.Core/Link/ConnectToFeature.cs +++ b/src/WixToolset.Core/Link/ConnectToFeature.cs @@ -1,6 +1,6 @@ // 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.Link +namespace WixToolset.Core.Link { using System.Collections.Generic; using WixToolset.Data; @@ -8,7 +8,7 @@ namespace WixToolset.Link /// /// Object that connects things (components/modules) to features. /// - public sealed class ConnectToFeature + internal class ConnectToFeature { /// /// Creates a new connect to feature. diff --git a/src/WixToolset.Core/Link/ConnectToFeatureCollection.cs b/src/WixToolset.Core/Link/ConnectToFeatureCollection.cs index 8dd0d22c..b7874527 100644 --- a/src/WixToolset.Core/Link/ConnectToFeatureCollection.cs +++ b/src/WixToolset.Core/Link/ConnectToFeatureCollection.cs @@ -1,6 +1,6 @@ // 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.Link +namespace WixToolset.Core.Link { using System; using System.Collections; @@ -8,7 +8,7 @@ namespace WixToolset.Link /// /// Hash collection of connect to feature objects. /// - public sealed class ConnectToFeatureCollection : ICollection + internal class ConnectToFeatureCollection : ICollection { private Hashtable collection; diff --git a/src/WixToolset.Core/Link/ConnectToModule.cs b/src/WixToolset.Core/Link/ConnectToModule.cs index d6a8338e..4380e12c 100644 --- a/src/WixToolset.Core/Link/ConnectToModule.cs +++ b/src/WixToolset.Core/Link/ConnectToModule.cs @@ -1,11 +1,11 @@ // 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.Link +namespace WixToolset.Core.Link { /// /// Object that connects things to modules. /// - public sealed class ConnectToModule + internal class ConnectToModule { private string childId; private string module; diff --git a/src/WixToolset.Core/Link/ConnectToModuleCollection.cs b/src/WixToolset.Core/Link/ConnectToModuleCollection.cs index 6595487f..e0f96ffb 100644 --- a/src/WixToolset.Core/Link/ConnectToModuleCollection.cs +++ b/src/WixToolset.Core/Link/ConnectToModuleCollection.cs @@ -1,6 +1,6 @@ // 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.Link +namespace WixToolset.Core.Link { using System; using System.Collections; @@ -8,7 +8,7 @@ namespace WixToolset.Link /// /// Hash collection of connect to module objects. /// - public sealed class ConnectToModuleCollection : ICollection + internal class ConnectToModuleCollection : ICollection { private Hashtable collection; diff --git a/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs b/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs index 23fac864..8d818ad9 100644 --- a/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs +++ b/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs @@ -1,13 +1,13 @@ // 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.Link +namespace WixToolset.Core.Link { using System.Collections.Generic; using System.Linq; using WixToolset.Data; using WixToolset.Extensibility.Services; - public class ReportConflictingSymbolsCommand + internal class ReportConflictingSymbolsCommand { public ReportConflictingSymbolsCommand(IMessaging messaging, IEnumerable possibleConflicts, IEnumerable resolvedSections) { diff --git a/src/WixToolset.Core/Link/ResolveReferencesCommand.cs b/src/WixToolset.Core/Link/ResolveReferencesCommand.cs index c05464e9..0188f9ac 100644 --- a/src/WixToolset.Core/Link/ResolveReferencesCommand.cs +++ b/src/WixToolset.Core/Link/ResolveReferencesCommand.cs @@ -1,6 +1,6 @@ // 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.Link +namespace WixToolset.Core.Link { using System; using System.Collections.Generic; diff --git a/src/WixToolset.Core/Link/WixGroupingOrdering.cs b/src/WixToolset.Core/Link/WixGroupingOrdering.cs index 50c4d8d2..4e89e607 100644 --- a/src/WixToolset.Core/Link/WixGroupingOrdering.cs +++ b/src/WixToolset.Core/Link/WixGroupingOrdering.cs @@ -16,7 +16,7 @@ namespace WixToolset.Core.Link /// /// Grouping and Ordering class of the WiX toolset. /// - internal sealed class WixGroupingOrdering + internal class WixGroupingOrdering { private IMessaging messageHandler; private List groupTypes; @@ -679,7 +679,7 @@ namespace WixToolset.Core.Link /// /// Helper IComparer class to make ordering easier. /// - internal sealed class AfterItemComparer : IComparer + internal class AfterItemComparer : IComparer { public int Compare(Item x, Item y) { diff --git a/src/WixToolset.Core/LinkContext.cs b/src/WixToolset.Core/LinkContext.cs index 7576ca3f..f45a3411 100644 --- a/src/WixToolset.Core/LinkContext.cs +++ b/src/WixToolset.Core/LinkContext.cs @@ -8,7 +8,7 @@ namespace WixToolset.Core using WixToolset.Extensibility; using WixToolset.Extensibility.Data; - public class LinkContext : ILinkContext + internal class LinkContext : ILinkContext { internal LinkContext(IServiceProvider serviceProvider) { diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs index 4d1a6965..04188e53 100644 --- a/src/WixToolset.Core/Linker.cs +++ b/src/WixToolset.Core/Linker.cs @@ -14,12 +14,11 @@ namespace WixToolset.Core using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; - using WixToolset.Link; /// /// Linker core of the WiX toolset. /// - public sealed class Linker + internal class Linker { private static readonly char[] colonCharacter = ":".ToCharArray(); private static readonly string emptyGuid = Guid.Empty.ToString("B"); @@ -29,7 +28,7 @@ namespace WixToolset.Core /// /// Creates a linker. /// - public Linker(IServiceProvider serviceProvider) + internal Linker(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; this.Messaging = this.ServiceProvider.GetService(); diff --git a/src/WixToolset.Core/Localizer.cs b/src/WixToolset.Core/Localizer.cs index cb9a4406..a545f844 100644 --- a/src/WixToolset.Core/Localizer.cs +++ b/src/WixToolset.Core/Localizer.cs @@ -11,31 +11,25 @@ namespace WixToolset.Core using WixToolset.Extensibility; using WixToolset.Extensibility.Services; - /// - /// Parses localization files and localizes database values. - /// - public sealed class Localizer + internal class Localizer : ILocalizer { public static readonly XNamespace WxlNamespace = "http://wixtoolset.org/schemas/v4/wxl"; private static string XmlElementName = "WixLocalization"; - /// - /// Loads a localization file from a path on disk. - /// - /// Path to localization file saved on disk. - /// Returns the loaded localization file. - public static Localization ParseLocalizationFile(IMessaging messaging, string path) + internal Localizer(IServiceProvider serviceProvider) + { + this.Messaging = serviceProvider.GetService(); + } + + private IMessaging Messaging { get; } + + public Localization ParseLocalizationFile(string path) { var document = XDocument.Load(path); - return ParseLocalizationFile(messaging, document); + return ParseLocalizationFile(document); } - /// - /// Loads a localization file from memory. - /// - /// Document to parse as localization file. - /// Returns the loaded localization file. - public static Localization ParseLocalizationFile(IMessaging messaging, XDocument document) + public Localization ParseLocalizationFile(XDocument document) { XElement root = document.Root; Localization localization = null; @@ -45,23 +39,23 @@ namespace WixToolset.Core { if (Localizer.WxlNamespace == root.Name.Namespace) { - localization = ParseWixLocalizationElement(messaging, root); + localization = ParseWixLocalizationElement(this.Messaging, root); } else // invalid or missing namespace { if (null == root.Name.Namespace) { - messaging.Write(ErrorMessages.InvalidWixXmlNamespace(sourceLineNumbers, Localizer.XmlElementName, Localizer.WxlNamespace.NamespaceName)); + this.Messaging.Write(ErrorMessages.InvalidWixXmlNamespace(sourceLineNumbers, Localizer.XmlElementName, Localizer.WxlNamespace.NamespaceName)); } else { - messaging.Write(ErrorMessages.InvalidWixXmlNamespace(sourceLineNumbers, Localizer.XmlElementName, root.Name.LocalName, Localizer.WxlNamespace.NamespaceName)); + this.Messaging.Write(ErrorMessages.InvalidWixXmlNamespace(sourceLineNumbers, Localizer.XmlElementName, root.Name.LocalName, Localizer.WxlNamespace.NamespaceName)); } } } else { - messaging.Write(ErrorMessages.InvalidDocumentElement(sourceLineNumbers, root.Name.LocalName, "localization", Localizer.XmlElementName)); + this.Messaging.Write(ErrorMessages.InvalidDocumentElement(sourceLineNumbers, root.Name.LocalName, "localization", Localizer.XmlElementName)); } return localization; diff --git a/src/WixToolset.Core/Mutator.cs b/src/WixToolset.Core/Mutator.cs index 7f1af13a..cee17736 100644 --- a/src/WixToolset.Core/Mutator.cs +++ b/src/WixToolset.Core/Mutator.cs @@ -10,7 +10,7 @@ namespace WixToolset.Core /// /// The WiX Toolset mutator. /// - public sealed class Mutator + public class Mutator { private SortedList extensions; private string extensionArgument; diff --git a/src/WixToolset.Core/OptimizeCA.cs b/src/WixToolset.Core/OptimizeCA.cs index efd07299..ba17604d 100644 --- a/src/WixToolset.Core/OptimizeCA.cs +++ b/src/WixToolset.Core/OptimizeCA.cs @@ -8,7 +8,7 @@ namespace WixToolset.Core /// Values for the OptimizeCA MsiPatchMetdata property, which indicates whether custom actions can be skipped when applying the patch. /// [Flags] - public enum OptimizeCA + internal enum OptimizeCA { /// /// No custom actions are skipped. diff --git a/src/WixToolset.Core/Preprocess/IfContext.cs b/src/WixToolset.Core/Preprocess/IfContext.cs index e7c6e6f5..91173c29 100644 --- a/src/WixToolset.Core/Preprocess/IfContext.cs +++ b/src/WixToolset.Core/Preprocess/IfContext.cs @@ -5,7 +5,7 @@ namespace WixToolset.Core.Preprocess /// /// Context for an if statement in the preprocessor. /// - internal sealed class IfContext + internal class IfContext { private bool keep; diff --git a/src/WixToolset.Core/Preprocess/ProcessedStreamEventHandler.cs b/src/WixToolset.Core/Preprocess/ProcessedStreamEventHandler.cs index 434590d2..b2a4ddb1 100644 --- a/src/WixToolset.Core/Preprocess/ProcessedStreamEventHandler.cs +++ b/src/WixToolset.Core/Preprocess/ProcessedStreamEventHandler.cs @@ -32,12 +32,12 @@ namespace WixToolset.Core.Preprocess /// Gets the full path of the source file. /// /// The full path of the source file. - public string SourceFile { get; private set; } + public string SourceFile { get; } /// /// Gets the preprocessed output stream. /// /// The the preprocessed output stream. - public XDocument Document { get; private set; } + public XDocument Document { get; } } } diff --git a/src/WixToolset.Core/Preprocessor.cs b/src/WixToolset.Core/Preprocessor.cs index aca954bd..acba0b5f 100644 --- a/src/WixToolset.Core/Preprocessor.cs +++ b/src/WixToolset.Core/Preprocessor.cs @@ -20,24 +20,24 @@ namespace WixToolset.Core /// /// Preprocessor object /// - public sealed class Preprocessor + internal class Preprocessor { - private readonly Regex defineRegex = new Regex(@"^\s*(?.+?)\s*(=\s*(?.+?)\s*)?$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); - private readonly Regex pragmaRegex = new Regex(@"^\s*(?.+?)(?[\s\(].+?)?$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); + private static readonly Regex DefineRegex = new Regex(@"^\s*(?.+?)\s*(=\s*(?.+?)\s*)?$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); + private static readonly Regex PragmaRegex = new Regex(@"^\s*(?.+?)(?[\s\(].+?)?$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); - private readonly XmlReaderSettings DocumentXmlReaderSettings = new XmlReaderSettings() + private static readonly XmlReaderSettings DocumentXmlReaderSettings = new XmlReaderSettings() { ValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags.None, XmlResolver = null, }; - private readonly XmlReaderSettings FragmentXmlReaderSettings = new XmlReaderSettings() + private static readonly XmlReaderSettings FragmentXmlReaderSettings = new XmlReaderSettings() { ConformanceLevel = ConformanceLevel.Fragment, ValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags.None, XmlResolver = null, }; - public Preprocessor(IServiceProvider serviceProvider) + internal Preprocessor(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; @@ -584,7 +584,7 @@ namespace WixToolset.Core /// Text from source. private void PreprocessDefine(string originalDefine) { - var match = defineRegex.Match(originalDefine); + var match = DefineRegex.Match(originalDefine); if (!match.Success) { @@ -791,7 +791,7 @@ namespace WixToolset.Core /// Text from source. private void PreprocessPragma(string pragmaText, XContainer parent) { - var match = pragmaRegex.Match(pragmaText); + var match = PragmaRegex.Match(pragmaText); if (!match.Success) { diff --git a/src/WixToolset.Core/ResolveContext.cs b/src/WixToolset.Core/ResolveContext.cs index 65b991ea..cadc6678 100644 --- a/src/WixToolset.Core/ResolveContext.cs +++ b/src/WixToolset.Core/ResolveContext.cs @@ -9,7 +9,7 @@ namespace WixToolset.Core using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; - public class ResolveContext : IResolveContext + internal class ResolveContext : IResolveContext { internal ResolveContext(IServiceProvider serviceProvider) { diff --git a/src/WixToolset.Core/Resolver.cs b/src/WixToolset.Core/Resolver.cs index 5e283f2c..12cb375b 100644 --- a/src/WixToolset.Core/Resolver.cs +++ b/src/WixToolset.Core/Resolver.cs @@ -15,9 +15,9 @@ namespace WixToolset.Core /// /// Resolver for the WiX toolset. /// - public sealed class Resolver + internal class Resolver { - public Resolver(IServiceProvider serviceProvider) + internal Resolver(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; @@ -26,7 +26,7 @@ namespace WixToolset.Core private IServiceProvider ServiceProvider { get; } - public IMessaging Messaging { get; } + private IMessaging Messaging { get; } public IEnumerable BindPaths { get; set; } diff --git a/src/WixToolset.Core/SourceFile.cs b/src/WixToolset.Core/SourceFile.cs index f1064513..d7ea7a50 100644 --- a/src/WixToolset.Core/SourceFile.cs +++ b/src/WixToolset.Core/SourceFile.cs @@ -2,8 +2,6 @@ namespace WixToolset.Core { - using System.IO; - internal class SourceFile { public SourceFile(string sourcePath, string outputPath) @@ -12,8 +10,8 @@ namespace WixToolset.Core this.OutputPath = outputPath; } - public string OutputPath { get; set; } + public string OutputPath { get; } - public string SourcePath { get; set; } + public string SourcePath { get; } } } diff --git a/src/WixToolset.Core/WixToolsetServiceProvider.cs b/src/WixToolset.Core/WixToolsetServiceProvider.cs index ffcdbdd1..9278ddc3 100644 --- a/src/WixToolset.Core/WixToolsetServiceProvider.cs +++ b/src/WixToolset.Core/WixToolsetServiceProvider.cs @@ -10,7 +10,7 @@ namespace WixToolset.Core using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; - public class WixToolsetServiceProvider : IServiceProvider + public sealed class WixToolsetServiceProvider : IServiceProvider { public WixToolsetServiceProvider() { @@ -36,6 +36,9 @@ namespace WixToolset.Core { typeof(IBindContext), (provider, singletons) => new BindContext(provider) }, { typeof(ILayoutContext), (provider, singletons) => new LayoutContext(provider) }, { typeof(IInscribeContext), (provider, singletons) => new InscribeContext(provider) }, + + // Internal implementations. + { typeof(ILocalizer), (provider, singletons) => new Localizer(provider) }, }; this.Singletons = new Dictionary(); diff --git a/src/WixToolset.Core/WixVariableResolver.cs b/src/WixToolset.Core/WixVariableResolver.cs index 8ac35e99..75851a56 100644 --- a/src/WixToolset.Core/WixVariableResolver.cs +++ b/src/WixToolset.Core/WixVariableResolver.cs @@ -12,7 +12,7 @@ namespace WixToolset.Core /// /// WiX variable resolver. /// - internal sealed class WixVariableResolver : IVariableResolver + internal class WixVariableResolver : IVariableResolver { private readonly Dictionary locVariables; private readonly Dictionary wixVariables; -- cgit v1.2.3-55-g6feb