From 8cf0427984a88b0b3ddfb2061e5be721afffe82e Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 17:19:56 -0700 Subject: Move Core into wix --- src/test/Example.Extension/Data/example.txt | 1 - src/test/Example.Extension/Data/example.wxs | 15 -- .../Example.Extension/Example.Extension.csproj | 24 --- .../Example.Extension/ExampleCompilerExtension.cs | 195 --------------------- src/test/Example.Extension/ExampleExtensionData.cs | 23 --- .../Example.Extension/ExampleExtensionFactory.cs | 54 ------ .../ExamplePreprocessorExtensionAndCommandLine.cs | 57 ------ src/test/Example.Extension/ExampleRow.cs | 32 ---- src/test/Example.Extension/ExampleSearchSymbol.cs | 30 ---- src/test/Example.Extension/ExampleSymbol.cs | 30 ---- .../Example.Extension/ExampleSymbolDefinitions.cs | 67 ------- .../Example.Extension/ExampleTableDefinitions.cs | 34 ---- .../ExampleWindowsInstallerBackendExtension.cs | 33 ---- 13 files changed, 595 deletions(-) delete mode 100644 src/test/Example.Extension/Data/example.txt delete mode 100644 src/test/Example.Extension/Data/example.wxs delete mode 100644 src/test/Example.Extension/Example.Extension.csproj delete mode 100644 src/test/Example.Extension/ExampleCompilerExtension.cs delete mode 100644 src/test/Example.Extension/ExampleExtensionData.cs delete mode 100644 src/test/Example.Extension/ExampleExtensionFactory.cs delete mode 100644 src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs delete mode 100644 src/test/Example.Extension/ExampleRow.cs delete mode 100644 src/test/Example.Extension/ExampleSearchSymbol.cs delete mode 100644 src/test/Example.Extension/ExampleSymbol.cs delete mode 100644 src/test/Example.Extension/ExampleSymbolDefinitions.cs delete mode 100644 src/test/Example.Extension/ExampleTableDefinitions.cs delete mode 100644 src/test/Example.Extension/ExampleWindowsInstallerBackendExtension.cs (limited to 'src/test/Example.Extension') diff --git a/src/test/Example.Extension/Data/example.txt b/src/test/Example.Extension/Data/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/Example.Extension/Data/example.txt +++ /dev/null @@ -1 +0,0 @@ -This is example.txt. \ No newline at end of file diff --git a/src/test/Example.Extension/Data/example.wxs b/src/test/Example.Extension/Data/example.wxs deleted file mode 100644 index af5d5086..00000000 --- a/src/test/Example.Extension/Data/example.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/Example.Extension/Example.Extension.csproj b/src/test/Example.Extension/Example.Extension.csproj deleted file mode 100644 index 9be10d35..00000000 --- a/src/test/Example.Extension/Example.Extension.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - netcoreapp3.1 - false - embedded - - - - - - - - - - - - - - - - diff --git a/src/test/Example.Extension/ExampleCompilerExtension.cs b/src/test/Example.Extension/ExampleCompilerExtension.cs deleted file mode 100644 index 5b8d4b3f..00000000 --- a/src/test/Example.Extension/ExampleCompilerExtension.cs +++ /dev/null @@ -1,195 +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 Example.Extension -{ - using System; - using System.Collections.Generic; - using System.Xml.Linq; - using WixToolset.Data; - using WixToolset.Extensibility; - - internal class ExampleCompilerExtension : BaseCompilerExtension - { - public override XNamespace Namespace => "http://www.example.com/scheams/v1/wxs"; - public string BundleExtensionId => "ExampleBundleExtension"; - - public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) - { - var processed = false; - - switch (parentElement.Name.LocalName) - { - case "Bundle": - case "Fragment": - switch (element.Name.LocalName) - { - case "ExampleEnsureTable": - this.ParseExampleEnsureTableElement(intermediate, section, element); - processed = true; - break; - case "ExampleSearch": - this.ParseExampleSearchElement(intermediate, section, element); - processed = true; - break; - case "ExampleSearchRef": - this.ParseExampleSearchRefElement(intermediate, section, element); - processed = true; - break; - } - break; - case "Component": - switch (element.Name.LocalName) - { - case "Example": - this.ParseExampleElement(intermediate, section, element); - processed = true; - break; - } - break; - } - - if (!processed) - { - base.ParseElement(intermediate, section, parentElement, element, context); - } - } - - private void ParseExampleElement(Intermediate intermediate, IntermediateSection section, XElement element) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - Identifier id = null; - string value = null; - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - - case "Value": - value = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseAttribute(intermediate, section, element, attrib, null); - } - } - - if (null == id) - { - //this.Messaging(WixErrors.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); - } - - if (!this.Messaging.EncounteredError) - { - var symbol = this.ParseHelper.CreateSymbol(section, sourceLineNumbers, "Example", id); - symbol.Set(0, value); - } - } - - private void ParseExampleEnsureTableElement(Intermediate intermediate, IntermediateSection section, XElement element) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - this.ParseHelper.EnsureTable(section, sourceLineNumbers, ExampleTableDefinitions.NotInAll); - } - - private void ParseExampleSearchElement(Intermediate intermediate, IntermediateSection section, XElement element) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - Identifier id = null; - string searchFor = null; - string variable = null; - string condition = null; - string after = null; - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Variable": - variable = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Condition": - condition = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "After": - after = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SearchFor": - searchFor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseAttribute(intermediate, section, element, attrib, null); - } - } - - if (null == id) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); - } - - if (!this.Messaging.EncounteredError) - { - this.ParseHelper.CreateWixSearchSymbol(section, sourceLineNumbers, element.Name.LocalName, id, variable, condition, after, this.BundleExtensionId); - } - - if (!this.Messaging.EncounteredError) - { - var symbol = section.AddSymbol(new ExampleSearchSymbol(sourceLineNumbers, id) - { - SearchFor = searchFor, - }); - } - } - - private void ParseExampleSearchRefElement(Intermediate intermediate, IntermediateSection section, XElement element) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - var refId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, ExampleSymbolDefinitions.ExampleSearch, refId); - break; - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); - } - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - } - } -} diff --git a/src/test/Example.Extension/ExampleExtensionData.cs b/src/test/Example.Extension/ExampleExtensionData.cs deleted file mode 100644 index 91d60eb9..00000000 --- a/src/test/Example.Extension/ExampleExtensionData.cs +++ /dev/null @@ -1,23 +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 Example.Extension -{ - using WixToolset.Data; - using WixToolset.Extensibility; - - internal class ExampleExtensionData : IExtensionData - { - public string DefaultCulture => null; - - public Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) - { - return Intermediate.Load(typeof(ExampleExtensionData).Assembly, "Example.Extension.Example.wixlib", symbolDefinitions); - } - - public bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) - { - symbolDefinition = ExampleSymbolDefinitions.ByName(name); - return symbolDefinition != null; - } - } -} \ No newline at end of file diff --git a/src/test/Example.Extension/ExampleExtensionFactory.cs b/src/test/Example.Extension/ExampleExtensionFactory.cs deleted file mode 100644 index e54561ee..00000000 --- a/src/test/Example.Extension/ExampleExtensionFactory.cs +++ /dev/null @@ -1,54 +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 Example.Extension -{ - using System; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Services; - - public class ExampleExtensionFactory : IExtensionFactory - { - private ExamplePreprocessorExtensionAndCommandLine preprocessorExtension; - - public ExampleExtensionFactory(IWixToolsetCoreServiceProvider serviceProvider) - { - this.ServiceProvider = serviceProvider; - } - - /// - /// This exists just to show it is possible to get a service provider to the extension factory. - /// - private IWixToolsetCoreServiceProvider ServiceProvider { get; } - - public bool TryCreateExtension(Type extensionType, out object extension) - { - if (extensionType == typeof(IExtensionCommandLine) || extensionType == typeof(IPreprocessorExtension)) - { - if (this.preprocessorExtension == null) - { - this.preprocessorExtension = new ExamplePreprocessorExtensionAndCommandLine(); - } - - extension = this.preprocessorExtension; - } - else if (extensionType == typeof(ICompilerExtension)) - { - extension = new ExampleCompilerExtension(); - } - else if (extensionType == typeof(IExtensionData)) - { - extension = new ExampleExtensionData(); - } - else if (extensionType == typeof(IWindowsInstallerBackendBinderExtension)) - { - extension = new ExampleWindowsInstallerBackendExtension(); - } - else - { - extension = null; - } - - return extension != null; - } - } -} diff --git a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs deleted file mode 100644 index 7244798a..00000000 --- a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs +++ /dev/null @@ -1,57 +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 Example.Extension -{ - using System; - using System.Collections.Generic; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Data; - using WixToolset.Extensibility.Services; - - internal class ExamplePreprocessorExtensionAndCommandLine : BasePreprocessorExtension, IExtensionCommandLine - { - private string exampleValueFromCommandLine; - - public IReadOnlyCollection CommandLineSwitches => throw new NotImplementedException(); - - public ExamplePreprocessorExtensionAndCommandLine() - { - this.Prefixes = new[] { "ex" }; - } - - public void PreParse(ICommandLineContext context) - { - } - - public bool TryParseArgument(ICommandLineParser parser, string argument) - { - if (parser.IsSwitch(argument) && argument.Substring(1).Equals("example", StringComparison.OrdinalIgnoreCase)) - { - this.exampleValueFromCommandLine = parser.GetNextArgumentOrError(argument); - return true; - } - - return false; - } - - public bool TryParseCommand(ICommandLineParser parser, string argument, out ICommandLineCommand command) - { - command = null; - return false; - } - - public void PostParse() - { - } - - public override string GetVariableValue(string prefix, string name) - { - if (prefix == "ex" && "test".Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return String.IsNullOrWhiteSpace(this.exampleValueFromCommandLine) ? "(null)" : this.exampleValueFromCommandLine; - } - - return null; - } - } -} diff --git a/src/test/Example.Extension/ExampleRow.cs b/src/test/Example.Extension/ExampleRow.cs deleted file mode 100644 index fc20c6c9..00000000 --- a/src/test/Example.Extension/ExampleRow.cs +++ /dev/null @@ -1,32 +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 Example.Extension -{ - using WixToolset.Data; - using WixToolset.Data.WindowsInstaller; - - public class ExampleRow : Row - { - public ExampleRow(SourceLineNumber sourceLineNumbers, Table table) - : base(sourceLineNumbers, table) - { - } - - public ExampleRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition) - : base(sourceLineNumbers, tableDefinition) - { - } - - public string Example - { - get { return (string)this.Fields[0].Data; } - set { this.Fields[0].Data = value; } - } - - public string Value - { - get { return (string)this.Fields[1].Data; } - set { this.Fields[1].Data = value; } - } - } -} diff --git a/src/test/Example.Extension/ExampleSearchSymbol.cs b/src/test/Example.Extension/ExampleSearchSymbol.cs deleted file mode 100644 index 40a39292..00000000 --- a/src/test/Example.Extension/ExampleSearchSymbol.cs +++ /dev/null @@ -1,30 +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 Example.Extension -{ - using WixToolset.Data; - - public enum ExampleSearchSymbolFields - { - SearchFor, - } - - public class ExampleSearchSymbol : IntermediateSymbol - { - public ExampleSearchSymbol() : base(ExampleSymbolDefinitions.ExampleSearch, null, null) - { - } - - public ExampleSearchSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(ExampleSymbolDefinitions.ExampleSearch, sourceLineNumber, id) - { - } - - public IntermediateField this[ExampleSymbolFields index] => this.Fields[(int)index]; - - public string SearchFor - { - get => this.Fields[(int)ExampleSearchSymbolFields.SearchFor]?.AsString(); - set => this.Set((int)ExampleSearchSymbolFields.SearchFor, value); - } - } -} diff --git a/src/test/Example.Extension/ExampleSymbol.cs b/src/test/Example.Extension/ExampleSymbol.cs deleted file mode 100644 index 314087e9..00000000 --- a/src/test/Example.Extension/ExampleSymbol.cs +++ /dev/null @@ -1,30 +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 Example.Extension -{ - using WixToolset.Data; - - public enum ExampleSymbolFields - { - Value, - } - - public class ExampleSymbol : IntermediateSymbol - { - public ExampleSymbol() : base(ExampleSymbolDefinitions.Example, null, null) - { - } - - public ExampleSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(ExampleSymbolDefinitions.Example, sourceLineNumber, id) - { - } - - public IntermediateField this[ExampleSymbolFields index] => this.Fields[(int)index]; - - public string Value - { - get => this.Fields[(int)ExampleSymbolFields.Value]?.AsString(); - set => this.Set((int)ExampleSymbolFields.Value, value); - } - } -} diff --git a/src/test/Example.Extension/ExampleSymbolDefinitions.cs b/src/test/Example.Extension/ExampleSymbolDefinitions.cs deleted file mode 100644 index f13d716d..00000000 --- a/src/test/Example.Extension/ExampleSymbolDefinitions.cs +++ /dev/null @@ -1,67 +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 Example.Extension -{ - using System; - using WixToolset.Data; - using WixToolset.Data.Burn; - - public enum ExampleSymbolDefinitionType - { - Example, - ExampleSearch, - } - - public static class ExampleSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition Example = new IntermediateSymbolDefinition( - ExampleSymbolDefinitionType.Example.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(ExampleSymbolFields.Value), IntermediateFieldType.String), - }, - typeof(ExampleSymbol)); - - public static readonly IntermediateSymbolDefinition ExampleSearch = new IntermediateSymbolDefinition( - ExampleSymbolDefinitionType.ExampleSearch.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(ExampleSearchSymbolFields.SearchFor), IntermediateFieldType.String), - }, - typeof(ExampleSearchSymbol)); - - static ExampleSymbolDefinitions() - { - ExampleSearch.AddTag(BurnConstants.BundleExtensionSearchSymbolDefinitionTag); - } - - public static bool TryGetSymbolType(string name, out ExampleSymbolDefinitionType type) - { - return Enum.TryParse(name, out type); - } - - public static IntermediateSymbolDefinition ByName(string name) - { - if (!TryGetSymbolType(name, out var type)) - { - return null; - } - return ByType(type); - } - - public static IntermediateSymbolDefinition ByType(ExampleSymbolDefinitionType type) - { - switch (type) - { - case ExampleSymbolDefinitionType.Example: - return ExampleSymbolDefinitions.Example; - - case ExampleSymbolDefinitionType.ExampleSearch: - return ExampleSymbolDefinitions.ExampleSearch; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - } - } -} diff --git a/src/test/Example.Extension/ExampleTableDefinitions.cs b/src/test/Example.Extension/ExampleTableDefinitions.cs deleted file mode 100644 index a2b81698..00000000 --- a/src/test/Example.Extension/ExampleTableDefinitions.cs +++ /dev/null @@ -1,34 +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 Example.Extension -{ - using WixToolset.Data.WindowsInstaller; - - public static class ExampleTableDefinitions - { - public static readonly TableDefinition ExampleTable = new TableDefinition( - "Wix4Example", - ExampleSymbolDefinitions.Example, - new[] - { - new ColumnDefinition("Example", ColumnType.String, 72, true, false, ColumnCategory.Identifier), - new ColumnDefinition("Value", ColumnType.String, 0, false, false, ColumnCategory.Formatted), - }, - strongRowType: typeof(ExampleRow), - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition NotInAll = new TableDefinition( - "TableDefinitionNotExposedByExtension", - null, - new[] - { - new ColumnDefinition("Example", ColumnType.String, 72, true, false, ColumnCategory.Identifier), - new ColumnDefinition("Value", ColumnType.String, 0, false, false, ColumnCategory.Formatted), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition[] All = new[] { ExampleTable }; - } -} diff --git a/src/test/Example.Extension/ExampleWindowsInstallerBackendExtension.cs b/src/test/Example.Extension/ExampleWindowsInstallerBackendExtension.cs deleted file mode 100644 index afccc56f..00000000 --- a/src/test/Example.Extension/ExampleWindowsInstallerBackendExtension.cs +++ /dev/null @@ -1,33 +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 Example.Extension -{ - using System.Collections.Generic; - using WixToolset.Data; - using WixToolset.Data.WindowsInstaller; - using WixToolset.Extensibility; - - internal class ExampleWindowsInstallerBackendExtension : BaseWindowsInstallerBackendBinderExtension - { - public override IReadOnlyCollection TableDefinitions => ExampleTableDefinitions.All; - - public override bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData output, TableDefinitionCollection tableDefinitions) - { - if (ExampleSymbolDefinitions.TryGetSymbolType(symbol.Definition.Name, out var symbolType)) - { - switch (symbolType) - { - case ExampleSymbolDefinitionType.Example: - { - var row = (ExampleRow)this.BackendHelper.CreateRow(section, symbol, output, ExampleTableDefinitions.ExampleTable); - row.Example = symbol.Id.Id; - row.Value = symbol[0].AsString(); - } - return true; - } - } - - return base.TryProcessSymbol(section, symbol, output, tableDefinitions); - } - } -} -- cgit v1.2.3-55-g6feb