Move to .NET Core 2.0
Rob Mensching committed
Aug 20, 2017 at 14:22 UTC
3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c
35 files changed
+1745
WixToolset.Extensibility.sln
new
+36
@@ -0,0 +1,36 @@
1
+Microsoft Visual Studio Solution File, Format Version 12.00
2
+# Visual Studio 15
3
+VisualStudioVersion = 15.0.26730.8
4
+MinimumVisualStudioVersion = 15.0.26124.0
5
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Extensibility", "src\WixToolset.Extensibility\WixToolset.Extensibility.csproj", "{AA049009-D7D9-4C63-8E0D-83206ADCFBD1}"
6
+EndProject
7
+Global
8
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
9
+ Debug|Any CPU = Debug|Any CPU
10
+ Debug|x64 = Debug|x64
11
+ Debug|x86 = Debug|x86
12
+ Release|Any CPU = Release|Any CPU
13
+ Release|x64 = Release|x64
14
+ Release|x86 = Release|x86
15
+ EndGlobalSection
16
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
17
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
19
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x64.ActiveCfg = Debug|Any CPU
20
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x64.Build.0 = Debug|Any CPU
21
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x86.ActiveCfg = Debug|Any CPU
22
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x86.Build.0 = Debug|Any CPU
23
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
24
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|Any CPU.Build.0 = Release|Any CPU
25
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x64.ActiveCfg = Release|Any CPU
26
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x64.Build.0 = Release|Any CPU
27
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x86.ActiveCfg = Release|Any CPU
28
+ {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x86.Build.0 = Release|Any CPU
29
+ EndGlobalSection
30
+ GlobalSection(SolutionProperties) = preSolution
31
+ HideSolutionNode = FALSE
32
+ EndGlobalSection
33
+ GlobalSection(ExtensibilityGlobals) = postSolution
34
+ SolutionGuid = {BB8820D5-723D-426D-B4A0-4D221603C5FA}
35
+ EndGlobalSection
36
+EndGlobal
src/Directory.Build.props
new
+18
@@ -0,0 +1,18 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<!-- 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. -->
3
+
4
+<Project>
5
+ <PropertyGroup>
6
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7
+ <BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
8
+ <OutputPath>$(MSBuildThisFileDirectory)..\build\$(Configuration)\</OutputPath>
9
+
10
+ <Authors>Rob Mensching, Bob Arnson</Authors>
11
+ <Company>WiX Toolset</Company>
12
+ <Copyright>Copyright (c) .NET Foundation and contributors. All rights reserved.</Copyright>
13
+ </PropertyGroup>
14
+
15
+ <PropertyGroup>
16
+ <WixToolsetRootFolder>$(MSBuildThisFileDirectory)..\..\</WixToolsetRootFolder>
17
+ </PropertyGroup>
18
+</Project>
src/WixToolset.Extensibility/AssemblyInfo.cs
new
+9
@@ -0,0 +1,9 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+using System;
4
+using System.Reflection;
5
+using System.Runtime.InteropServices;
6
+
7
+[assembly: AssemblyCulture("")]
8
+[assembly:CLSCompliant(true)]
9
+[assembly: ComVisible(false)]
src/WixToolset.Extensibility/BindFileWithPath.cs
new
+20
@@ -0,0 +1,20 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ /// <summary>
6
+ /// Bind file with its path.
7
+ /// </summary>
8
+ public class BindFileWithPath
9
+ {
10
+ /// <summary>
11
+ /// Gets or sets the identifier of the file with this path.
12
+ /// </summary>
13
+ public string Id { get; set; }
14
+
15
+ /// <summary>
16
+ /// Gets or sets the file path.
17
+ /// </summary>
18
+ public string Path { get; set; }
19
+ }
20
+}
src/WixToolset.Extensibility/BindPath.cs
new
+52
@@ -0,0 +1,52 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+
7
+ /// <summary>
8
+ /// Bind path representation.
9
+ /// </summary>
10
+ public class BindPath
11
+ {
12
+ /// <summary>
13
+ /// Creates an unnamed bind path.
14
+ /// </summary>
15
+ /// <param name="path">Path for the bind path.</param>
16
+ public BindPath(string path) : this(String.Empty, path)
17
+ {
18
+ }
19
+
20
+ /// <summary>
21
+ /// Creates a named bind path.
22
+ /// </summary>
23
+ /// <param name="name">Name of the bind path.</param>
24
+ /// <param name="path">Path for the bind path.</param>
25
+ public BindPath(string name, string path)
26
+ {
27
+ this.Name = name;
28
+ this.Path = path;
29
+ }
30
+
31
+ /// <summary>
32
+ /// Parses a bind path from its string representation
33
+ /// </summary>
34
+ /// <param name="bindPath">String representation of bind path that looks like: [name=]path</param>
35
+ /// <returns>Parsed bind path.</returns>
36
+ public static BindPath Parse(string bindPath)
37
+ {
38
+ string[] namedPath = bindPath.Split(new char[] { '=' }, 2);
39
+ return (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]);
40
+ }
41
+
42
+ /// <summary>
43
+ /// Name of the bind path or String.Empty if the path is unnamed.
44
+ /// </summary>
45
+ public string Name { get; set; }
46
+
47
+ /// <summary>
48
+ /// Path for the bind path.
49
+ /// </summary>
50
+ public string Path { get; set; }
51
+ }
52
+}
src/WixToolset.Extensibility/BindStage.cs
new
+27
@@ -0,0 +1,27 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ /// <summary>
6
+ /// Bind stage of a file.. The reason we need this is to change the ResolveFile behavior based on if
7
+ /// dynamic bindpath plugin is desirable. We cannot change the signature of ResolveFile since it might
8
+ /// break existing implementers which derived from BinderFileManager
9
+ /// </summary>
10
+ public enum BindStage
11
+ {
12
+ /// <summary>
13
+ /// Normal binding
14
+ /// </summary>
15
+ Normal,
16
+
17
+ /// <summary>
18
+ /// Bind the file path of the target build file
19
+ /// </summary>
20
+ Target,
21
+
22
+ /// <summary>
23
+ /// Bind the file path of the updated build file
24
+ /// </summary>
25
+ Updated,
26
+ }
27
+}
src/WixToolset.Extensibility/BinderExtension.cs
new
+40
@@ -0,0 +1,40 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ /// <summary>
8
+ /// Base class for creating an binder extension.
9
+ /// </summary>
10
+ public abstract class BinderExtension : IBinderExtension
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the binder core for the extension.
14
+ /// </summary>
15
+ /// <value>Binder core for the extension.</value>
16
+ public IBinderCore Core { get; set; }
17
+
18
+
19
+ /// <summary>
20
+ /// Called before binding occurs.
21
+ /// </summary>
22
+ public virtual void Initialize(Output output)
23
+ {
24
+ }
25
+
26
+ /// <summary>
27
+ /// Called after variable resolution occurs.
28
+ /// </summary>
29
+ public virtual void AfterResolvedFields(Output output)
30
+ {
31
+ }
32
+
33
+ /// <summary>
34
+ /// Called after all output changes occur and right before the output is bound into its final format.
35
+ /// </summary>
36
+ public virtual void Finish(Output output)
37
+ {
38
+ }
39
+ }
40
+}
src/WixToolset.Extensibility/CabinetBuildOption.cs
new
+25
@@ -0,0 +1,25 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ /// <summary>
6
+ /// Options for building the cabinet.
7
+ /// </summary>
8
+ public enum CabinetBuildOption
9
+ {
10
+ /// <summary>
11
+ /// Build the cabinet and move it to the target location.
12
+ /// </summary>
13
+ BuildAndMove,
14
+
15
+ /// <summary>
16
+ /// Build the cabinet and copy it to the target location.
17
+ /// </summary>
18
+ BuildAndCopy,
19
+
20
+ /// <summary>
21
+ /// Just copy the cabinet to the target location.
22
+ /// </summary>
23
+ Copy
24
+ }
25
+}
src/WixToolset.Extensibility/CompilerConstants.cs
new
+19
@@ -0,0 +1,19 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset
4
+{
5
+ using System;
6
+
7
+ /// <summary>
8
+ /// Constants used by compiler.
9
+ /// </summary>
10
+ public class CompilerConstants
11
+ {
12
+ public const int IntegerNotSet = int.MinValue;
13
+ public const int IllegalInteger = int.MinValue + 1;
14
+ public const long LongNotSet = long.MinValue;
15
+ public const long IllegalLong = long.MinValue + 1;
16
+ public const string IllegalGuid = "IllegalGuid";
17
+ public static readonly Version IllegalVersion = new Version(Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue);
18
+ }
19
+}
src/WixToolset.Extensibility/CompilerExtension.cs
new
+74
@@ -0,0 +1,74 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System.Collections.Generic;
6
+ using System.Xml.Linq;
7
+
8
+ /// <summary>
9
+ /// Base class for creating a compiler extension.
10
+ /// </summary>
11
+ public abstract class CompilerExtension : ICompilerExtension
12
+ {
13
+ /// <summary>
14
+ /// Gets or sets the compiler core for the extension.
15
+ /// </summary>
16
+ /// <value>Compiler core for the extension.</value>
17
+ public ICompilerCore Core { get; set; }
18
+
19
+ /// <summary>
20
+ /// Gets the schema namespace for this extension.
21
+ /// </summary>
22
+ /// <value>Schema namespace supported by this extension.</value>
23
+ public XNamespace Namespace { get; protected set; }
24
+
25
+ /// <summary>
26
+ /// Called at the beginning of the compilation of a source file.
27
+ /// </summary>
28
+ public virtual void Initialize()
29
+ {
30
+ }
31
+
32
+ /// <summary>
33
+ /// Processes an attribute for the Compiler.
34
+ /// </summary>
35
+ /// <param name="parentElement">Parent element of attribute.</param>
36
+ /// <param name="attribute">Attribute to process.</param>
37
+ /// <param name="context">Extra information about the context in which this element is being parsed.</param>
38
+ public virtual void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary<string, string> context)
39
+ {
40
+ this.Core.UnexpectedAttribute(parentElement, attribute);
41
+ }
42
+
43
+ /// <summary>
44
+ /// Processes an element for the Compiler.
45
+ /// </summary>
46
+ /// <param name="parentElement">Parent element of element to process.</param>
47
+ /// <param name="element">Element to process.</param>
48
+ /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
49
+ public virtual void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context)
50
+ {
51
+ this.Core.UnexpectedElement(parentElement, element);
52
+ }
53
+
54
+ /// <summary>
55
+ /// Processes an element for the Compiler, with the ability to supply a component keypath.
56
+ /// </summary>
57
+ /// <param name="parentElement">Parent element of element to process.</param>
58
+ /// <param name="element">Element to process.</param>
59
+ /// <param name="keyPath">Explicit key path.</param>
60
+ /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
61
+ public virtual ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary<string, string> context)
62
+ {
63
+ this.ParseElement(parentElement, element, context);
64
+ return null;
65
+ }
66
+
67
+ /// <summary>
68
+ /// Called at the end of the compilation of a source file.
69
+ /// </summary>
70
+ public virtual void Finish()
71
+ {
72
+ }
73
+ }
74
+}
src/WixToolset.Extensibility/ComponentKeyPath.cs
new
+57
@@ -0,0 +1,57 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+
7
+ public enum ComponentKeyPathType
8
+ {
9
+ /// <summary>
10
+ /// Not a key path.
11
+ /// </summary>
12
+ None,
13
+
14
+ /// <summary>
15
+ /// File resource as a key path.
16
+ /// </summary>
17
+ File,
18
+
19
+ /// <summary>
20
+ /// Folder as a key path.
21
+ /// </summary>
22
+ Directory,
23
+
24
+ /// <summary>
25
+ /// ODBC data source as a key path.
26
+ /// </summary>
27
+ OdbcDataSource,
28
+
29
+ /// <summary>
30
+ /// A simple registry key acting as a key path.
31
+ /// </summary>
32
+ Registry,
33
+
34
+ /// <summary>
35
+ /// A registry key that contains a formatted property acting as a key path.
36
+ /// </summary>
37
+ RegistryFormatted
38
+ }
39
+
40
+ public class ComponentKeyPath
41
+ {
42
+ /// <summary>
43
+ /// Identifier of the resource to be a key path.
44
+ /// </summary>
45
+ public string Id { get; set; }
46
+
47
+ /// <summary>
48
+ /// Indicates whether the key path was explicitly set for this resource.
49
+ /// </summary>
50
+ public bool Explicit { get; set; }
51
+
52
+ /// <summary>
53
+ /// Type of resource to be the key path.
54
+ /// </summary>
55
+ public ComponentKeyPathType Type { get; set; }
56
+ }
57
+}
src/WixToolset.Extensibility/DecompilerConstants.cs
new
+15
@@ -0,0 +1,15 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset
4
+{
5
+ using System;
6
+
7
+ /// <summary>
8
+ /// Constants used by decompiler.
9
+ /// </summary>
10
+ public class DecompilerConstants
11
+ {
12
+ public const char PrimaryKeyDelimiter = '/';
13
+ public const string PrimaryKeyDelimiterString = "/";
14
+ }
15
+}
src/WixToolset.Extensibility/DecompilerExtension.cs
new
+59
@@ -0,0 +1,59 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ /// <summary>
8
+ /// Base class for creating a decompiler extension.
9
+ /// </summary>
10
+ public abstract class DecompilerExtension : IDecompilerExtension
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the decompiler core for the extension.
14
+ /// </summary>
15
+ /// <value>The decompiler core for the extension.</value>
16
+ public IDecompilerCore Core { get; set; }
17
+
18
+ /// <summary>
19
+ /// Gets the table definitions this extension decompiles.
20
+ /// </summary>
21
+ /// <value>Table definitions this extension decompiles.</value>
22
+ public virtual TableDefinitionCollection TableDefinitions { get; protected set; }
23
+
24
+ /// <summary>
25
+ /// Gets the library that this decompiler wants removed from the decomipiled output.
26
+ /// </summary>
27
+ /// <param name="tableDefinitions">The table definitions to use while loading the library.</param>
28
+ /// <returns>The library for this extension or null if there is no library to be removed.</returns>
29
+ public virtual Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions)
30
+ {
31
+ return null;
32
+ }
33
+
34
+ /// <summary>
35
+ /// Called at the beginning of the decompilation of a database.
36
+ /// </summary>
37
+ /// <param name="tables">The collection of all tables.</param>
38
+ public virtual void Initialize(TableIndexedCollection tables)
39
+ {
40
+ }
41
+
42
+ /// <summary>
43
+ /// Decompiles an extension table.
44
+ /// </summary>
45
+ /// <param name="table">The table to decompile.</param>
46
+ public virtual void DecompileTable(Table table)
47
+ {
48
+ this.Core.UnexpectedTable(table);
49
+ }
50
+
51
+ /// <summary>
52
+ /// Finalize decompilation.
53
+ /// </summary>
54
+ /// <param name="tables">The collection of all tables.</param>
55
+ public virtual void Finish(TableIndexedCollection tables)
56
+ {
57
+ }
58
+ }
59
+}
src/WixToolset.Extensibility/ExtensionData.cs
new
+75
@@ -0,0 +1,75 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using System.Reflection;
8
+ using System.Xml;
9
+ using WixToolset.Data;
10
+
11
+ public abstract class ExtensionData : IExtensionData
12
+ {
13
+ /// <summary>
14
+ /// Gets the optional table definitions for this extension.
15
+ /// </summary>
16
+ /// <value>Table definisions for this extension or null if there are no table definitions.</value>
17
+ public virtual TableDefinitionCollection TableDefinitions
18
+ {
19
+ get { return null; }
20
+ }
21
+
22
+ /// <summary>
23
+ /// Gets the optional default culture.
24
+ /// </summary>
25
+ /// <value>The optional default culture.</value>
26
+ public virtual string DefaultCulture
27
+ {
28
+ get { return null; }
29
+ }
30
+
31
+ /// <summary>
32
+ /// Gets the optional library associated with this extension.
33
+ /// </summary>
34
+ /// <param name="tableDefinitions">The table definitions to use while loading the library.</param>
35
+ /// <returns>The library for this extension or null if there is no library.</returns>
36
+ public virtual Library GetLibrary(TableDefinitionCollection tableDefinitions)
37
+ {
38
+ return null;
39
+ }
40
+
41
+ /// <summary>
42
+ /// Help for loading a library from an embedded resource.
43
+ /// </summary>
44
+ /// <param name="assembly">The assembly containing the embedded resource.</param>
45
+ /// <param name="resourceName">The name of the embedded resource being requested.</param>
46
+ /// <param name="tableDefinitions">The table definitions to use while loading the library.</param>
47
+ /// <returns>The loaded library.</returns>
48
+ protected static Library LoadLibraryHelper(Assembly assembly, string resourceName, TableDefinitionCollection tableDefinitions)
49
+ {
50
+ using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
51
+ {
52
+ UriBuilder uriBuilder = new UriBuilder(assembly.CodeBase);
53
+ uriBuilder.Scheme = "embeddedresource";
54
+ uriBuilder.Fragment = resourceName;
55
+
56
+ return Library.Load(resourceStream, uriBuilder.Uri, tableDefinitions, false);
57
+ }
58
+ }
59
+
60
+ /// <summary>
61
+ /// Helper for loading table definitions from an embedded resource.
62
+ /// </summary>
63
+ /// <param name="assembly">The assembly containing the embedded resource.</param>
64
+ /// <param name="resourceName">The name of the embedded resource being requested.</param>
65
+ /// <returns>The loaded table definitions.</returns>
66
+ protected static TableDefinitionCollection LoadTableDefinitionHelper(Assembly assembly, string resourceName)
67
+ {
68
+ using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
69
+ using (XmlReader reader = XmlReader.Create(resourceStream))
70
+ {
71
+ return TableDefinitionCollection.Load(reader);
72
+ }
73
+ }
74
+ }
75
+}
src/WixToolset.Extensibility/ExtensionHelper.cs
new
+53
@@ -0,0 +1,53 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using System.Collections.Specialized;
7
+ using System.IO;
8
+ using System.Reflection;
9
+ using System.Xml;
10
+ using WixToolset.Data;
11
+ using WixToolset.Extensibility;
12
+
13
+ /// <summary>
14
+ /// The main class for a WiX extension.
15
+ /// </summary>
16
+ public static class ExtensionHelper
17
+ {
18
+ /// <summary>
19
+ /// Help for loading a library from an embedded resource.
20
+ /// </summary>
21
+ /// <param name="assembly">The assembly containing the embedded resource.</param>
22
+ /// <param name="resourceName">The name of the embedded resource being requested.</param>
23
+ /// <param name="tableDefinitions">The table definitions to use while loading the library.</param>
24
+ /// <returns>The loaded library.</returns>
25
+ public static Library LoadLibraryHelper(Assembly assembly, string resourceName, TableDefinitionCollection tableDefinitions)
26
+ {
27
+ using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
28
+ {
29
+ UriBuilder uriBuilder = new UriBuilder();
30
+ uriBuilder.Scheme = "embeddedresource";
31
+ uriBuilder.Path = assembly.Location;
32
+ uriBuilder.Fragment = resourceName;
33
+
34
+ return Library.Load(resourceStream, uriBuilder.Uri, tableDefinitions, false);
35
+ }
36
+ }
37
+
38
+ /// <summary>
39
+ /// Helper for loading table definitions from an embedded resource.
40
+ /// </summary>
41
+ /// <param name="assembly">The assembly containing the embedded resource.</param>
42
+ /// <param name="resourceName">The name of the embedded resource being requested.</param>
43
+ /// <returns>The loaded table definitions.</returns>
44
+ public static TableDefinitionCollection LoadTableDefinitionHelper(Assembly assembly, string resourceName)
45
+ {
46
+ using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
47
+ using (XmlReader reader = XmlReader.Create(resourceStream))
48
+ {
49
+ return TableDefinitionCollection.Load(reader);
50
+ }
51
+ }
52
+ }
53
+}
src/WixToolset.Extensibility/IBinderCore.cs
new
+35
@@ -0,0 +1,35 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ public interface IBinderCore : IMessageHandler
8
+ {
9
+ /// <summary>
10
+ /// Gets or sets the file manager core for the extension.
11
+ /// </summary>
12
+ /// <value>File manager core for the extension.</value>
13
+ IBinderFileManagerCore FileManagerCore { get; set; }
14
+
15
+ /// <summary>
16
+ /// Gets whether the binder core encountered an error while processing.
17
+ /// </summary>
18
+ /// <value>Flag if core encountered an error during processing.</value>
19
+ bool EncounteredError { get; }
20
+
21
+ /// <summary>
22
+ /// Gets the table definitions used by the Binder.
23
+ /// </summary>
24
+ /// <value>Table definitions used by the binder.</value>
25
+ TableDefinitionCollection TableDefinitions { get; }
26
+
27
+ /// <summary>
28
+ /// Generate an identifier by hashing data from the row.
29
+ /// </summary>
30
+ /// <param name="prefix">Three letter or less prefix for generated row identifier.</param>
31
+ /// <param name="args">Information to hash.</param>
32
+ /// <returns>The generated identifier.</returns>
33
+ string CreateIdentifier(string prefix, params string[] args);
34
+ }
35
+}
src/WixToolset.Extensibility/IBinderExtension.cs
new
+33
@@ -0,0 +1,33 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ /// <summary>
8
+ /// Interface all binder extensions implement.
9
+ /// </summary>
10
+ public interface IBinderExtension
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the binder core for the extension.
14
+ /// </summary>
15
+ /// <value>Binder core for the extension.</value>
16
+ IBinderCore Core { get; set; }
17
+
18
+ /// <summary>
19
+ /// Called before binding occurs.
20
+ /// </summary>
21
+ void Initialize(Output output);
22
+
23
+ /// <summary>
24
+ /// Called after variable resolution occurs.
25
+ /// </summary>
26
+ void AfterResolvedFields(Output output);
27
+
28
+ /// <summary>
29
+ /// Called after all output changes occur and right before the output is bound into its final format.
30
+ /// </summary>
31
+ void Finish(Output output);
32
+ }
33
+}
src/WixToolset.Extensibility/IBinderFileManager.cs
new
+29
@@ -0,0 +1,29 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System.Collections.Generic;
6
+ using WixToolset.Data;
7
+ using WixToolset.Data.Rows;
8
+
9
+ public interface IBinderFileManager
10
+ {
11
+ IBinderFileManagerCore Core { set; }
12
+
13
+ ResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable<BindFileWithPath> files);
14
+
15
+ string ResolveFile(string source, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage);
16
+
17
+ string ResolveRelatedFile(string source, string relatedSource, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage);
18
+
19
+ string ResolveMedia(MediaRow mediaRow, string mediaLayoutDirectory, string layoutDirectory);
20
+
21
+ string ResolveUrl(string url, string fallbackUrl, string packageId, string payloadId, string fileName);
22
+
23
+ bool? CompareFiles(string targetFile, string updatedFile);
24
+
25
+ bool CopyFile(string source, string destination, bool overwrite);
26
+
27
+ bool MoveFile(string source, string destination, bool overwrite);
28
+ }
29
+}
src/WixToolset.Extensibility/IBinderFileManagerCore.cs
new
+54
@@ -0,0 +1,54 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System.Collections.Generic;
6
+ using WixToolset.Data;
7
+
8
+ public interface IBinderFileManagerCore : IMessageHandler
9
+ {
10
+ /// <summary>
11
+ /// Gets or sets the path to cabinet cache.
12
+ /// </summary>
13
+ /// <value>The path to cabinet cache.</value>
14
+ string CabCachePath { get; }
15
+
16
+ /// <summary>
17
+ /// Gets or sets the active subStorage used for binding.
18
+ /// </summary>
19
+ /// <value>The subStorage object.</value>
20
+ SubStorage ActiveSubStorage { get; }
21
+
22
+ /// <summary>
23
+ /// Gets or sets the output object used for binding.
24
+ /// </summary>
25
+ /// <value>The output object.</value>
26
+ Output Output { get; }
27
+
28
+ /// <summary>
29
+ /// Gets or sets the path to the temp files location.
30
+ /// </summary>
31
+ /// <value>The path to the temp files location.</value>
32
+ string TempFilesLocation { get; }
33
+
34
+ /// <summary>
35
+ /// Gets the property if re-basing target is true or false
36
+ /// </summary>
37
+ /// <value>It returns true if target bind path is to be replaced, otherwise false.</value>
38
+ bool RebaseTarget { get; }
39
+
40
+ /// <summary>
41
+ /// Gets the property if re-basing updated build is true or false
42
+ /// </summary>
43
+ /// <value>It returns true if updated bind path is to be replaced, otherwise false.</value>
44
+ bool RebaseUpdated { get; }
45
+
46
+ /// <summary>
47
+ /// Gets the collection of paths to locate files during ResolveFile for the provided BindStage and name.
48
+ /// </summary>
49
+ /// <param name="stage">Optional stage to get bind paths for. Default is normal.</param>
50
+ /// <param name="name">Optional name of the bind paths to get. Default is the unnamed paths.</param>
51
+ /// <value>The bind paths to locate files.</value>
52
+ IEnumerable<string> GetBindPaths(BindStage stage = BindStage.Normal, string name = null);
53
+ }
54
+}
src/WixToolset.Extensibility/ICompilerCore.cs
new
+339
@@ -0,0 +1,339 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using System.Collections;
7
+ using System.Collections.Generic;
8
+ using System.Xml.Linq;
9
+ using WixToolset.Data;
10
+
11
+ /// <summary>
12
+ /// Core interface provided by the compiler.
13
+ /// </summary>
14
+ public interface ICompilerCore : IMessageHandler
15
+ {
16
+ /// <summary>
17
+ /// Gets whether the compiler core encountered an error while processing.
18
+ /// </summary>
19
+ /// <value>Flag if core encountered an error during processing.</value>
20
+ bool EncounteredError { get; }
21
+
22
+ /// <summary>
23
+ /// Gets the platform which the compiler will use when defaulting 64-bit attributes and elements.
24
+ /// </summary>
25
+ /// <value>The platform which the compiler will use when defaulting 64-bit attributes and elements.</value>
26
+ Platform CurrentPlatform { get; }
27
+
28
+ /// <summary>
29
+ /// Creates a version 3 name-based UUID.
30
+ /// </summary>
31
+ /// <param name="namespaceGuid">The namespace UUID.</param>
32
+ /// <param name="value">The value.</param>
33
+ /// <returns>The generated GUID for the given namespace and value.</returns>
34
+ string CreateGuid(Guid namespaceGuid, string value);
35
+
36
+ /// <summary>
37
+ /// Create an identifier by hashing data from the row.
38
+ /// </summary>
39
+ /// <param name="prefix">Three letter or less prefix for generated row identifier.</param>
40
+ /// <param name="args">Information to hash.</param>
41
+ /// <returns>The new identifier.</returns>
42
+ Identifier CreateIdentifier(string prefix, params string[] args);
43
+
44
+ /// <summary>
45
+ /// Create an identifier based on passed file name
46
+ /// </summary>
47
+ /// <param name="name">File name to generate identifer from</param>
48
+ /// <returns></returns>
49
+ Identifier CreateIdentifierFromFilename(string filename);
50
+
51
+ /// <summary>
52
+ /// Convert a bit array into an int value.
53
+ /// </summary>
54
+ /// <param name="bits">The bit array to convert.</param>
55
+ /// <returns>The converted int value.</returns>
56
+ int CreateIntegerFromBitArray(BitArray bits);
57
+
58
+ /// <summary>
59
+ /// Creates a row in the active section.
60
+ /// </summary>
61
+ /// <param name="sourceLineNumbers">Source and line number of current row.</param>
62
+ /// <param name="tableName">Name of table to create row in.</param>
63
+ /// <param name="identifier">Optional identifier for the row.</param>
64
+ /// <returns>New row.</returns>
65
+ Row CreateRow(SourceLineNumber sourceLineNumbers, string tableName, Identifier identifier = null);
66
+
67
+ /// <summary>
68
+ /// Creates directories using the inline directory syntax.
69
+ /// </summary>
70
+ /// <param name="sourceLineNumbers">Source line information.</param>
71
+ /// <param name="attribute">The attribute to parse.</param>
72
+ /// <param name="parentId">Optional identifier of parent directory.</param>
73
+ /// <returns>Identifier of the leaf directory created.</returns>
74
+ string CreateDirectoryReferenceFromInlineSyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId);
75
+
76
+ /// <summary>
77
+ /// Creates a Registry row in the active section.
78
+ /// </summary>
79
+ /// <param name="sourceLineNumbers">Source and line number of the current row.</param>
80
+ /// <param name="root">The registry entry root.</param>
81
+ /// <param name="key">The registry entry key.</param>
82
+ /// <param name="name">The registry entry name.</param>
83
+ /// <param name="value">The registry entry value.</param>
84
+ /// <param name="componentId">The component which will control installation/uninstallation of the registry entry.</param>
85
+ /// <param name="escapeLeadingHash">If true, "escape" leading '#' characters so the value is written as a REG_SZ.</param>
86
+ Identifier CreateRegistryRow(SourceLineNumber sourceLineNumbers, int root, string key, string name, string value, string componentId, bool escapeLeadingHash = false);
87
+
88
+ /// <summary>
89
+ /// Creates a short file/directory name using an identifier and long file/directory name as input.
90
+ /// </summary>
91
+ /// <param name="longName">The long file/directory name.</param>
92
+ /// <param name="keepExtension">The option to keep the extension on generated short names.</param>
93
+ /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
94
+ /// <param name="args">Any additional information to include in the hash for the generated short name.</param>
95
+ /// <returns>The generated 8.3-compliant short file/directory name.</returns>
96
+ string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args);
97
+
98
+ /// <summary>
99
+ /// Create a WixSimpleReference row in the active section.
100
+ /// </summary>
101
+ /// <param name="sourceLineNumbers">Source line information for the row.</param>
102
+ /// <param name="tableName">The table name of the simple reference.</param>
103
+ /// <param name="primaryKeys">The primary keys of the simple reference.</param>
104
+ void CreateSimpleReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys);
105
+
106
+ /// <summary>
107
+ /// Creates WixComplexReference and WixGroup rows in the active section.
108
+ /// </summary>
109
+ /// <param name="sourceLineNumbers">Source line information.</param>
110
+ /// <param name="parentType">The parent type.</param>
111
+ /// <param name="parentId">The parent id.</param>
112
+ /// <param name="parentLanguage">The parent language.</param>
113
+ /// <param name="childType">The child type.</param>
114
+ /// <param name="childId">The child id.</param>
115
+ /// <param name="isPrimary">Whether the child is primary.</param>
116
+ void CreateComplexReference(SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary);
117
+
118
+ /// <summary>
119
+ /// Creates a patch resource reference to the list of resoures to be filtered when producing a patch. This method should only be used when processing children of a patch family.
120
+ /// </summary>
121
+ /// <param name="sourceLineNumbers">Source and line number of current row.</param>
122
+ /// <param name="tableName">Name of table to create row in.</param>
123
+ /// <param name="primaryKeys">Array of keys that make up the primary key of the table.</param>
124
+ /// <returns>New row.</returns>
125
+ void CreatePatchFamilyChildReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys);
126
+
127
+ /// <summary>
128
+ /// Checks if the string contains a property (i.e. "foo[Property]bar")
129
+ /// </summary>
130
+ /// <param name="possibleProperty">String to evaluate for properties.</param>
131
+ /// <returns>True if a property is found in the string.</returns>
132
+ bool ContainsProperty(string possibleProperty);
133
+
134
+ /// <summary>
135
+ /// Add the appropriate rows to make sure that the given table shows up in the resulting output.
136
+ /// </summary>
137
+ /// <param name="sourceLineNumbers">Source line numbers.</param>
138
+ /// <param name="tableName">Name of the table to ensure existance of.</param>
139
+ void EnsureTable(SourceLineNumber sourceLineNumbers, string tableName);
140
+
141
+ /// <summary>
142
+ /// Get an attribute value and displays an error if the value is empty by default.
143
+ /// </summary>
144
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
145
+ /// <param name="attribute">The attribute containing the value to get.</param>
146
+ /// <param name="emptyRule">A rule for the contents of the value. If the contents do not follow the rule, an error is thrown.</param>
147
+ /// <returns>The attribute's value.</returns>
148
+ string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule = EmptyRule.CanBeWhitespaceOnly);
149
+
150
+ /// <summary>
151
+ /// Gets a Bundle variable value and displays an error for an illegal value.
152
+ /// </summary>
153
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
154
+ /// <param name="attribute">The attribute containing the value to get.</param>
155
+ /// <returns>The attribute's value.</returns>
156
+ string GetAttributeBundleVariableValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
157
+
158
+ /// <summary>
159
+ /// Get a guid attribute value and displays an error for an illegal guid value.
160
+ /// </summary>
161
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
162
+ /// <param name="attribute">The attribute containing the value to get.</param>
163
+ /// <param name="generatable">Determines whether the guid can be automatically generated.</param>
164
+ /// <param name="canBeEmpty">If true, no error is raised on empty value. If false, an error is raised.</param>
165
+ /// <returns>The attribute's guid value or a special value if an error occurred.</returns>
166
+ string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false);
167
+
168
+ /// <summary>
169
+ /// Get an identifier attribute value and displays an error for an illegal identifier value.
170
+ /// </summary>
171
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
172
+ /// <param name="attribute">The attribute containing the value to get.</param>
173
+ /// <returns>The attribute's identifier value or a special value if an error occurred.</returns>
174
+ Identifier GetAttributeIdentifier(SourceLineNumber sourceLineNumbers, XAttribute attribute);
175
+
176
+ /// <summary>
177
+ /// Get an identifier attribute value and displays an error for an illegal identifier value.
178
+ /// </summary>
179
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
180
+ /// <param name="attribute">The attribute containing the value to get.</param>
181
+ /// <returns>The attribute's identifier value or a special value if an error occurred.</returns>
182
+ string GetAttributeIdentifierValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
183
+
184
+ /// <summary>
185
+ /// Get an integer attribute value and displays an error for an illegal integer value.
186
+ /// </summary>
187
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
188
+ /// <param name="attribute">The attribute containing the value to get.</param>
189
+ /// <param name="minimum">The minimum legal value.</param>
190
+ /// <param name="maximum">The maximum legal value.</param>
191
+ /// <returns>The attribute's integer value or a special value if an error occurred during conversion.</returns>
192
+ int GetAttributeIntegerValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, int minimum, int maximum);
193
+
194
+ /// <summary>
195
+ /// Get a long integral attribute value and displays an error for an illegal long value.
196
+ /// </summary>
197
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
198
+ /// <param name="attribute">The attribute containing the value to get.</param>
199
+ /// <param name="minimum">The minimum legal value.</param>
200
+ /// <param name="maximum">The maximum legal value.</param>
201
+ /// <returns>The attribute's long value or a special value if an error occurred during conversion.</returns>
202
+ long GetAttributeLongValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, long minimum, long maximum);
203
+
204
+ /// <summary>
205
+ /// Gets a long filename value and displays an error for an illegal long filename value.
206
+ /// </summary>
207
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
208
+ /// <param name="attribute">The attribute containing the value to get.</param>
209
+ /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
210
+ /// <param name="allowRelative">true if relative paths are allowed in the filename.</param>
211
+ /// <returns>The attribute's long filename value.</returns>
212
+ string GetAttributeLongFilename(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowWildcards = false, bool allowRelative = false);
213
+
214
+ /// <summary>
215
+ /// Gets a RegistryRoot as a MsiInterop.MsidbRegistryRoot value and displays an error for an illegal value.
216
+ /// </summary>
217
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
218
+ /// <param name="attribute">The attribute containing the value to get.</param>
219
+ /// <param name="allowHkmu">Whether HKMU is returned as -1 (true), or treated as an error (false).</param>
220
+ /// <returns>The attribute's RegisitryRootType value.</returns>
221
+ int GetAttributeMsidbRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu);
222
+
223
+ /// <summary>
224
+ /// Gets a version value or possibly a binder variable and displays an error for an illegal version value.
225
+ /// </summary>
226
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
227
+ /// <param name="attribute">The attribute containing the value to get.</param>
228
+ /// <returns>The attribute's version value.</returns>
229
+ string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
230
+
231
+ /// <summary>
232
+ /// Gets a yes/no value and displays an error for an illegal yes/no value.
233
+ /// </summary>
234
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
235
+ /// <param name="attribute">The attribute containing the value to get.</param>
236
+ /// <returns>The attribute's YesNoType value.</returns>
237
+ YesNoType GetAttributeYesNoValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
238
+
239
+ /// <summary>
240
+ /// Gets a yes/no/default value and displays an error for an illegal yes/no/default value.
241
+ /// </summary>
242
+ /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
243
+ /// <param name="attribute">The attribute containing the value to get.</param>
244
+ /// <returns>The attribute's YesNoType value.</returns>
245
+ YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
246
+
247
+ /// <summary>
248
+ /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace.
249
+ /// </summary>
250
+ /// <param name="node">The node to ensure inner text is a condition.</param>
251
+ /// <returns>The value converted into a safe condition.</returns>
252
+ string GetConditionInnerText(XElement node);
253
+
254
+ /// <summary>
255
+ /// Get an element's inner text and trims any extra whitespace.
256
+ /// </summary>
257
+ /// <param name="element">The element with inner text to be trimmed.</param>
258
+ /// <returns>The node's inner text trimmed.</returns>
259
+ string GetTrimmedInnerText(XElement element);
260
+
261
+ /// <summary>
262
+ /// Verifies that a value is a legal identifier.
263
+ /// </summary>
264
+ /// <param name="value">The value to verify.</param>
265
+ /// <returns>true if the value is an identifier; false otherwise.</returns>
266
+ bool IsValidIdentifier(string value);
267
+
268
+ /// <summary>
269
+ /// Verifies if an identifier is a valid loc identifier.
270
+ /// </summary>
271
+ /// <param name="identifier">Identifier to verify.</param>
272
+ /// <returns>True if the identifier is a valid loc identifier.</returns>
273
+ bool IsValidLocIdentifier(string identifier);
274
+
275
+ /// <summary>
276
+ /// Verifies if a filename is a valid long filename.
277
+ /// </summary>
278
+ /// <param name="filename">Filename to verify.</param>
279
+ /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
280
+ /// <param name="allowRelative">true if relative paths are allowed in the filename.</param>
281
+ /// <returns>True if the filename is a valid long filename</returns>
282
+ bool IsValidLongFilename(string filename, bool allowWildcards = false, bool allowRelative = false);
283
+
284
+ /// <summary>
285
+ /// Verifies if a filename is a valid short filename.
286
+ /// </summary>
287
+ /// <param name="filename">Filename to verify.</param>
288
+ /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
289
+ /// <returns>True if the filename is a valid short filename</returns>
290
+ bool IsValidShortFilename(string filename, bool allowWildcards = false);
291
+
292
+ /// <summary>
293
+ /// Attempts to use an extension to parse the attribute.
294
+ /// </summary>
295
+ /// <param name="element">Element containing attribute to be parsed.</param>
296
+ /// <param name="attribute">Attribute to be parsed.</param>
297
+ /// <param name="context">Extra information about the context in which this element is being parsed.</param>
298
+ void ParseExtensionAttribute(XElement element, XAttribute attribute, IDictionary<string, string> context = null);
299
+
300
+ /// <summary>
301
+ /// Attempts to use an extension to parse the element.
302
+ /// </summary>
303
+ /// <param name="parentElement">Element containing element to be parsed.</param>
304
+ /// <param name="element">Element to be parsed.</param>
305
+ /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
306
+ void ParseExtensionElement(XElement parentElement, XElement element, IDictionary<string, string> context = null);
307
+
308
+ /// <summary>
309
+ /// Process all children of the element looking for extensions and erroring on the unexpected.
310
+ /// </summary>
311
+ /// <param name="element">Element to parse children.</param>
312
+ void ParseForExtensionElements(XElement element);
313
+
314
+ /// <summary>
315
+ /// Sets a bit in a bit array based on the index at which an attribute name was found in a string array.
316
+ /// </summary>
317
+ /// <param name="attributeNames">Array of attributes that map to bits.</param>
318
+ /// <param name="attributeName">Name of attribute to check.</param>
319
+ /// <param name="attributeValue">Value of attribute to check.</param>
320
+ /// <param name="bits">The bit array in which the bit will be set if found.</param>
321
+ /// <param name="offset">The offset into the bit array.</param>
322
+ /// <returns>true if the bit was set; false otherwise.</returns>
323
+ bool TrySetBitFromName(string[] attributeNames, string attributeName, YesNoType attributeValue, BitArray bits, int offset);
324
+
325
+ /// <summary>
326
+ /// Called when the compiler encounters an unexpected attribute.
327
+ /// </summary>
328
+ /// <param name="parentElement">Parent element that found unexpected attribute.</param>
329
+ /// <param name="attribute">Unexpected attribute.</param>
330
+ void UnexpectedAttribute(XElement element, XAttribute attribute);
331
+
332
+ /// <summary>
333
+ /// Called when the compiler encounters an unexpected child element.
334
+ /// </summary>
335
+ /// <param name="parentElement">Parent element that found unexpected child.</param>
336
+ /// <param name="childElement">Unexpected child element.</param>
337
+ void UnexpectedElement(XElement parentElement, XElement childElement);
338
+ }
339
+}
src/WixToolset.Extensibility/ICompilerExtension.cs
new
+59
@@ -0,0 +1,59 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System.Collections.Generic;
6
+ using System.Xml.Linq;
7
+
8
+ /// <summary>
9
+ /// Interface all compiler extensions implement.
10
+ /// </summary>
11
+ public interface ICompilerExtension
12
+ {
13
+ /// <summary>
14
+ /// Gets or sets the compiler core for the extension.
15
+ /// </summary>
16
+ /// <value>Compiler core for the extension.</value>
17
+ ICompilerCore Core { get; set; }
18
+
19
+ /// <summary>
20
+ /// Gets the schema namespace for this extension.
21
+ /// </summary>
22
+ /// <value>Schema namespace supported by this extension.</value>
23
+ XNamespace Namespace { get; }
24
+
25
+ /// <summary>
26
+ /// Called at the beginning of the compilation of a source file.
27
+ /// </summary>
28
+ void Initialize();
29
+
30
+ /// <summary>
31
+ /// Processes an attribute for the Compiler.
32
+ /// </summary>
33
+ /// <param name="parentElement">Parent element of attribute.</param>
34
+ /// <param name="attribute">Attribute to process.</param>
35
+ /// <param name="context">Extra information about the context in which this element is being parsed.</param>
36
+ void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary<string, string> context);
37
+
38
+ /// <summary>
39
+ /// Processes an element for the Compiler.
40
+ /// </summary>
41
+ /// <param name="parentElement">Parent element of element to process.</param>
42
+ /// <param name="element">Element to process.</param>
43
+ /// <param name="context">Extra information about the context in which this element is being parsed.</param>
44
+ void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context);
45
+
46
+ /// <summary>
47
+ /// Processes an element for the Compiler, with the ability to supply a component keypath.
48
+ /// </summary>
49
+ /// <param name="parentElement">Parent element of element to process.</param>
50
+ /// <param name="element">Element to process.</param>
51
+ /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
52
+ ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary<string, string> context);
53
+
54
+ /// <summary>
55
+ /// Called at the end of the compilation of a source file.
56
+ /// </summary>
57
+ void Finish();
58
+ }
59
+}
src/WixToolset.Extensibility/IDecompilerCore.cs
new
+73
@@ -0,0 +1,73 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using WixToolset.Data;
7
+ using Wix = WixToolset.Data.Serialize;
8
+
9
+ public interface IDecompilerCore : IMessageHandler
10
+ {
11
+
12
+ /// <summary>
13
+ /// Gets whether the decompiler core encountered an error while processing.
14
+ /// </summary>
15
+ /// <value>Flag if core encountered an error during processing.</value>
16
+ bool EncounteredError { get; }
17
+
18
+ /// <summary>
19
+ /// Gets the root element of the decompiled output.
20
+ /// </summary>
21
+ /// <value>The root element of the decompiled output.</value>
22
+ Wix.IParentElement RootElement { get; }
23
+
24
+ /// <summary>
25
+ /// Gets the UI element.
26
+ /// </summary>
27
+ /// <value>The UI element.</value>
28
+ Wix.UI UIElement { get; }
29
+
30
+ /// <summary>
31
+ /// Verifies if a filename is a valid short filename.
32
+ /// </summary>
33
+ /// <param name="filename">Filename to verify.</param>
34
+ /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
35
+ /// <returns>True if the filename is a valid short filename</returns>
36
+ bool IsValidShortFilename(string filename, bool allowWildcards);
37
+
38
+ /// <summary>
39
+ /// Convert an Int32 into a DateTime.
40
+ /// </summary>
41
+ /// <param name="value">The Int32 value.</param>
42
+ /// <returns>The DateTime.</returns>
43
+ DateTime ConvertIntegerToDateTime(int value);
44
+
45
+ /// <summary>
46
+ /// Gets the element corresponding to the row it came from.
47
+ /// </summary>
48
+ /// <param name="row">The row corresponding to the element.</param>
49
+ /// <returns>The indexed element.</returns>
50
+ Wix.ISchemaElement GetIndexedElement(Row row);
51
+
52
+ /// <summary>
53
+ /// Gets the element corresponding to the primary key of the given table.
54
+ /// </summary>
55
+ /// <param name="table">The table corresponding to the element.</param>
56
+ /// <param name="primaryKey">The primary key corresponding to the element.</param>
57
+ /// <returns>The indexed element.</returns>
58
+ Wix.ISchemaElement GetIndexedElement(string table, params string[] primaryKey);
59
+
60
+ /// <summary>
61
+ /// Index an element by its corresponding row.
62
+ /// </summary>
63
+ /// <param name="row">The row corresponding to the element.</param>
64
+ /// <param name="element">The element to index.</param>
65
+ void IndexElement(Row row, Wix.ISchemaElement element);
66
+
67
+ /// <summary>
68
+ /// Indicates the decompiler encountered and unexpected table to decompile.
69
+ /// </summary>
70
+ /// <param name="table">Unknown decompiled table.</param>
71
+ void UnexpectedTable(Table table);
72
+}
73
+}
src/WixToolset.Extensibility/IDecompilerExtension.cs
new
+49
@@ -0,0 +1,49 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ /// <summary>
8
+ /// Base class for creating a decompiler extension.
9
+ /// </summary>
10
+ public interface IDecompilerExtension
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the decompiler core for the extension.
14
+ /// </summary>
15
+ /// <value>The decompiler core for the extension.</value>
16
+ IDecompilerCore Core { get; set; }
17
+
18
+ /// <summary>
19
+ /// Gets the table definitions this extension decompiles.
20
+ /// </summary>
21
+ /// <value>Table definitions this extension decompiles.</value>
22
+ TableDefinitionCollection TableDefinitions { get; }
23
+
24
+ /// <summary>
25
+ /// Gets the library that this decompiler wants removed from the decomipiled output.
26
+ /// </summary>
27
+ /// <param name="tableDefinitions">The table definitions to use while loading the library.</param>
28
+ /// <returns>The library for this extension or null if there is no library to be removed.</returns>
29
+ Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions);
30
+
31
+ /// <summary>
32
+ /// Called at the beginning of the decompilation of a database.
33
+ /// </summary>
34
+ /// <param name="tables">The collection of all tables.</param>
35
+ void Initialize(TableIndexedCollection tables);
36
+
37
+ /// <summary>
38
+ /// Decompiles an extension table.
39
+ /// </summary>
40
+ /// <param name="table">The table to decompile.</param>
41
+ void DecompileTable(Table table);
42
+
43
+ /// <summary>
44
+ /// Finalize decompilation.
45
+ /// </summary>
46
+ /// <param name="tables">The collection of all tables.</param>
47
+ void Finish(TableIndexedCollection tables);
48
+ }
49
+}
src/WixToolset.Extensibility/IExtensionCommandLine.cs
new
+42
@@ -0,0 +1,42 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System.Collections.Generic;
6
+ using WixToolset.Data;
7
+
8
+ /// <summary>
9
+ /// A command line option.
10
+ /// </summary>
11
+ public struct ExtensionCommandLineSwitch
12
+ {
13
+ public string Switch { get; set; }
14
+
15
+ public string Description { get; set; }
16
+ }
17
+
18
+ /// <summary>
19
+ /// Interface extensions implement to be able to parse command-line options.
20
+ /// </summary>
21
+ public interface IExtensionCommandLine
22
+ {
23
+ /// <summary>
24
+ /// Sets the message handler for the extension.
25
+ /// </summary>
26
+ /// <value>Message handler for the extension.</value>
27
+ IMessageHandler MessageHandler { set; }
28
+
29
+ /// <summary>
30
+ /// Gets the supported command line types for this extension.
31
+ /// </summary>
32
+ /// <value>The supported command line types for this extension.</value>
33
+ IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches { get; }
34
+
35
+ /// <summary>
36
+ /// Parse the commandline arguments.
37
+ /// </summary>
38
+ /// <param name="args">Commandline arguments.</param>
39
+ /// <returns>Unparsed commandline arguments.</returns>
40
+ string[] ParseCommandLine(string[] args);
41
+ }
42
+}
src/WixToolset.Extensibility/IExtensionData.cs
new
+31
@@ -0,0 +1,31 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ /// <summary>
8
+ /// Interface extensions implement to provide data.
9
+ /// </summary>
10
+ public interface IExtensionData
11
+ {
12
+ /// <summary>
13
+ /// Gets the table definitions for this extension.
14
+ /// </summary>
15
+ /// <value>Table definisions for this extension or null if there are no table definitions.</value>
16
+ TableDefinitionCollection TableDefinitions { get; }
17
+
18
+ /// <summary>
19
+ /// Gets the optional default culture.
20
+ /// </summary>
21
+ /// <value>The optional default culture.</value>
22
+ string DefaultCulture { get; }
23
+
24
+ /// <summary>
25
+ /// Gets the library associated with this extension.
26
+ /// </summary>
27
+ /// <param name="tableDefinitions">The table definitions to use while loading the library.</param>
28
+ /// <returns>The library for this extension or null if there is no library.</returns>
29
+ Library GetLibrary(TableDefinitionCollection tableDefinitions);
30
+ }
31
+}
src/WixToolset.Extensibility/IInspectorCore.cs
new
+17
@@ -0,0 +1,17 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ /// <summary>
8
+ /// Core facilities for inspector extensions.
9
+ /// </summary>
10
+ public interface IInspectorCore : IMessageHandler
11
+ {
12
+ /// <summary>
13
+ /// Gets whether an error occured.
14
+ /// </summary>
15
+ bool EncounteredError { get; }
16
+ }
17
+}
src/WixToolset.Extensibility/IInspectorExtension.cs
new
+59
@@ -0,0 +1,59 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using WixToolset.Data;
8
+
9
+ /// <summary>
10
+ /// Interface for inspector extensions.
11
+ /// </summary>
12
+ /// <remarks>
13
+ /// The inspector methods are stateless, but extensions are loaded and last for the lifetime of the
14
+ /// containing classes like <see cref="Preprocessor"/>, <see cref="Compiler"/>, <see cref="Linker"/>,
15
+ /// <see cref="Differ"/>, and <see cref="Binder"/>. If you want to maintain state, you should check
16
+ /// if your data is loaded for each method and, if not, load it.
17
+ /// </remarks>
18
+ public interface IInspectorExtension
19
+ {
20
+ /// <summary>
21
+ /// Gets or sets the <see cref="InspectorCore"/> for inspector extensions to use.
22
+ /// </summary>
23
+ IInspectorCore Core { get; set; }
24
+
25
+ /// <summary>
26
+ /// Inspect the source before preprocessing.
27
+ /// </summary>
28
+ /// <param name="source">The source to preprocess.</param>
29
+ void InspectSource(Stream source);
30
+
31
+ /// <summary>
32
+ /// Inspect the compiled output.
33
+ /// </summary>
34
+ /// <param name="intermediate">The compiled output.</param>
35
+ void InspectIntermediate(Intermediate intermediate);
36
+
37
+ /// <summary>
38
+ /// Inspect the output.
39
+ /// </summary>
40
+ /// <param name="output">The output. May be called after linking or binding.</param>
41
+ /// <remarks>
42
+ /// To inspect a patch's filtered transforms, enumerate <see cref="Output.SubStorages"/>.
43
+ /// Transforms where the <see cref="SubStorage.Name"/> begins with "#" are
44
+ /// called patch transforms and instruct Windows Installer how to apply the
45
+ /// authored transforms - those that do not begin with "#". The authored
46
+ /// transforms are the primary transforms you'll typically want to inspect
47
+ /// and contain your changes to target products.
48
+ /// </remarks>
49
+ void InspectOutput(Output output);
50
+
51
+ /// <summary>
52
+ /// Inspect the final output after binding.
53
+ /// </summary>
54
+ /// <param name="filePath">The file path to the final bound output.</param>
55
+ /// <param name="pdb">The <see cref="Pdb"/> that contains source line numbers
56
+ /// for the database and all rows.</param>
57
+ void InspectDatabase(string filePath, Pdb pdb);
58
+ }
59
+}
src/WixToolset.Extensibility/IPreprocessorCore.cs
new
+21
@@ -0,0 +1,21 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ public interface IPreprocessorCore : IMessageHandler
8
+ {
9
+ /// <summary>
10
+ /// Gets or sets the platform which the compiler will use when defaulting 64-bit attributes and elements.
11
+ /// </summary>
12
+ /// <value>The platform which the compiler will use when defaulting 64-bit attributes and elements.</value>
13
+ Platform CurrentPlatform { get; }
14
+
15
+ /// <summary>
16
+ /// Gets whether the core encountered an error while processing.
17
+ /// </summary>
18
+ /// <value>Flag if core encountered an error during processing.</value>
19
+ bool EncounteredError { get; }
20
+ }
21
+}
src/WixToolset.Extensibility/IPreprocessorExtension.cs
new
+79
@@ -0,0 +1,79 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using System.Xml.Linq;
7
+ using WixToolset.Data;
8
+
9
+ /// <summary>
10
+ /// Interface for extending the WiX toolset preprocessor.
11
+ /// </summary>
12
+ public interface IPreprocessorExtension
13
+ {
14
+ /// <summary>
15
+ /// Gets or sets the preprocessor core for the extension.
16
+ /// </summary>
17
+ /// <value>Preprocessor core for the extension.</value>
18
+ IPreprocessorCore Core { get; set; }
19
+
20
+ /// <summary>
21
+ /// Gets the variable prefixes for the extension.
22
+ /// </summary>
23
+ /// <value>The variable prefixes for the extension.</value>
24
+ string[] Prefixes { get; }
25
+
26
+ /// <summary>
27
+ /// Called at the beginning of the preprocessing of a source file.
28
+ /// </summary>
29
+ void Initialize();
30
+
31
+ /// <summary>
32
+ /// Gets the value of a variable whose prefix matches the extension.
33
+ /// </summary>
34
+ /// <param name="prefix">The prefix of the variable to be processed by the extension.</param>
35
+ /// <param name="name">The name of the variable.</param>
36
+ /// <returns>The value of the variable or null if the variable is undefined.</returns>
37
+ string GetVariableValue(string prefix, string name);
38
+
39
+ /// <summary>
40
+ /// Evaluates a function defined in the extension.
41
+ /// </summary>
42
+ /// <param name="prefix">The prefix of the function to be processed by the extension.</param>
43
+ /// <param name="function">The name of the function.</param>
44
+ /// <param name="args">The list of arguments.</param>
45
+ /// <returns>The value of the function or null if the function is not defined.</returns>
46
+ string EvaluateFunction(string prefix, string function, string[] args);
47
+
48
+ /// <summary>
49
+ /// Processes a pragma defined in the extension.
50
+ /// </summary>
51
+ /// <param name="sourceLineNumbers">The location of this pragma's PI.</param>
52
+ /// <param name="prefix">The prefix of the pragma to be processed by the extension.</param>
53
+ /// <param name="pragma">The name of the pragma.</param>
54
+ /// <param name="args">The pragma's arguments.</param>
55
+ /// <param name="parent">The parent node of the pragma.</param>
56
+ /// <returns>false if the pragma is not defined.</returns>
57
+ /// <comments>Don't return false for any condition except for unrecognized pragmas. Use Core.OnMessage for errors, warnings and messages.</comments>
58
+ bool ProcessPragma(SourceLineNumber sourceLineNumbers, string prefix, string pragma, string args, XContainer parent);
59
+
60
+ /// <summary>
61
+ /// Preprocess a document after normal preprocessing has completed.
62
+ /// </summary>
63
+ /// <param name="document">The document to preprocess.</param>
64
+ void PreprocessDocument(XDocument document);
65
+
66
+ /// <summary>
67
+ /// Preprocesses a parameter.
68
+ /// </summary>
69
+ /// <param name="name">Name of parameter that matches extension.</param>
70
+ /// <returns>The value of the parameter after processing.</returns>
71
+ /// <remarks>By default this method will cause an error if its called.</remarks>
72
+ string PreprocessParameter(string name);
73
+
74
+ /// <summary>
75
+ /// Called at the end of the preprocessing of a source file.
76
+ /// </summary>
77
+ void Finish();
78
+ }
79
+}
src/WixToolset.Extensibility/IUnbinderExtension.cs
new
+18
@@ -0,0 +1,18 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using WixToolset.Data;
7
+
8
+ /// <summary>
9
+ /// Base class for creating an unbinder extension.
10
+ /// </summary>
11
+ public interface IUnbinderExtension
12
+ {
13
+ /// <summary>
14
+ /// Called during the generation of sectionIds for an admin image.
15
+ /// </summary>
16
+ void GenerateSectionIds(Output output);
17
+ }
18
+}
src/WixToolset.Extensibility/Identifier.cs
new
+31
@@ -0,0 +1,31 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using WixToolset.Data;
7
+
8
+ /// <summary>
9
+ /// Class to define the identifier and access for a row.
10
+ /// </summary>
11
+ public class Identifier
12
+ {
13
+ public static Identifier Invalid = new Identifier(null, AccessModifier.Private);
14
+
15
+ public Identifier(string id, AccessModifier access)
16
+ {
17
+ this.Id = id;
18
+ this.Access = access;
19
+ }
20
+
21
+ /// <summary>
22
+ /// Access modifier for a row.
23
+ /// </summary>
24
+ public AccessModifier Access { get; private set; }
25
+
26
+ /// <summary>
27
+ /// Identifier for the row.
28
+ /// </summary>
29
+ public string Id { get; private set; }
30
+ }
31
+}
src/WixToolset.Extensibility/InspectorExtension.cs
new
+61
@@ -0,0 +1,61 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System;
6
+ using System.IO;
7
+ using WixToolset.Data;
8
+
9
+ /// <summary>
10
+ /// Opitonal base class for inspector extensions.
11
+ /// </summary>
12
+ public class InspectorExtension : IInspectorExtension
13
+ {
14
+ /// <summary>
15
+ /// Gets the <see cref="InspectorCore"/> for inspector extensions to use.
16
+ /// </summary>
17
+ public IInspectorCore Core { get; set; }
18
+
19
+ /// <summary>
20
+ /// Inspect the source before preprocessing.
21
+ /// </summary>
22
+ /// <param name="source">The source to preprocess.</param>
23
+ public virtual void InspectSource(Stream source)
24
+ {
25
+ }
26
+
27
+ /// <summary>
28
+ /// Inspect the compiled output.
29
+ /// </summary>
30
+ /// <param name="intermediate">The compiled output.</param>
31
+ public virtual void InspectIntermediate(Intermediate intermediate)
32
+ {
33
+ }
34
+
35
+ /// <summary>
36
+ /// Inspect the output.
37
+ /// </summary>
38
+ /// <param name="output">The output. May be called after linking or binding.</param>
39
+ /// <remarks>
40
+ /// To inspect a patch's filtered transforms, enumerate <see cref="Output.SubStorages"/>.
41
+ /// Transforms where the <see cref="SubStorage.Name"/> begins with "#" are
42
+ /// called patch transforms and instruct Windows Installer how to apply the
43
+ /// authored transforms - those that do not begin with "#". The authored
44
+ /// transforms are the primary transforms you'll typically want to inspect
45
+ /// and contain your changes to target products.
46
+ /// </remarks>
47
+ public virtual void InspectOutput(Output output)
48
+ {
49
+ }
50
+
51
+ /// <summary>
52
+ /// Inspect the final output after binding.
53
+ /// </summary>
54
+ /// <param name="filePath">The file path to the final bound output.</param>
55
+ /// <param name="pdb">The <see cref="Pdb"/> that contains source line numbers
56
+ /// for the database and all rows.</param>
57
+ public virtual void InspectDatabase(string filePath, Pdb pdb)
58
+ {
59
+ }
60
+ }
61
+}
src/WixToolset.Extensibility/PreprocessorExtension.cs
new
+99
@@ -0,0 +1,99 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using System.Xml.Linq;
6
+ using WixToolset.Data;
7
+
8
+ /// <summary>
9
+ /// Base class for creating a preprocessor extension.
10
+ /// </summary>
11
+ public abstract class PreprocessorExtension : IPreprocessorExtension
12
+ {
13
+ /// <summary>
14
+ /// Gets or sets the preprocessor core for the extension.
15
+ /// </summary>
16
+ /// <value>Preprocessor core for the extension.</value>
17
+ public IPreprocessorCore Core { get; set; }
18
+
19
+ /// <summary>
20
+ /// Gets or sets the variable prefixes for the extension.
21
+ /// </summary>
22
+ /// <value>The variable prefixes for the extension.</value>
23
+ public virtual string[] Prefixes
24
+ {
25
+ get { return null; }
26
+ }
27
+
28
+ /// <summary>
29
+ /// Called at the beginning of the preprocessing of a source file.
30
+ /// </summary>
31
+ public virtual void Initialize()
32
+ {
33
+ }
34
+
35
+ /// <summary>
36
+ /// Gets the value of a variable whose prefix matches the extension.
37
+ /// </summary>
38
+ /// <param name="prefix">The prefix of the variable to be processed by the extension.</param>
39
+ /// <param name="name">The name of the variable.</param>
40
+ /// <returns>The value of the variable or null if the variable is undefined.</returns>
41
+ public virtual string GetVariableValue(string prefix, string name)
42
+ {
43
+ return null;
44
+ }
45
+
46
+ /// <summary>
47
+ /// Evaluates a function defined in the extension.
48
+ /// </summary>
49
+ /// <param name="prefix">The prefix of the function to be processed by the extension.</param>
50
+ /// <param name="function">The name of the function.</param>
51
+ /// <param name="args">The list of arguments.</param>
52
+ /// <returns>The value of the function or null if the function is not defined.</returns>
53
+ public virtual string EvaluateFunction(string prefix, string function, string[] args)
54
+ {
55
+ return null;
56
+ }
57
+
58
+ /// <summary>
59
+ /// Processes a pragma defined in the extension.
60
+ /// </summary>
61
+ /// <param name="sourceLineNumbers">The location of this pragma's PI.</param>
62
+ /// <param name="prefix">The prefix of the pragma to be processed by the extension.</param>
63
+ /// <param name="pragma">The name of the pragma.</param>
64
+ /// <param name="args">The pragma's arguments.</param>
65
+ /// <param name="parent">The parent node of the pragma.</param>
66
+ /// <returns>false if the pragma is not defined.</returns>
67
+ /// <comments>Don't return false for any condition except for unrecognized pragmas. Throw errors that are fatal to the compile. use core.OnMessage for warnings and messages.</comments>
68
+ public virtual bool ProcessPragma(SourceLineNumber sourceLineNumbers, string prefix, string pragma, string args, XContainer parent)
69
+ {
70
+ return false;
71
+ }
72
+
73
+ /// <summary>
74
+ /// Preprocess a document after normal preprocessing has completed.
75
+ /// </summary>
76
+ /// <param name="document">The document to preprocess.</param>
77
+ public virtual void PreprocessDocument(XDocument document)
78
+ {
79
+ }
80
+
81
+ /// <summary>
82
+ /// Preprocesses a parameter.
83
+ /// </summary>
84
+ /// <param name="name">Name of parameter that matches extension.</param>
85
+ /// <returns>The value of the parameter after processing.</returns>
86
+ /// <remarks>By default this method will cause an error if its called.</remarks>
87
+ public virtual string PreprocessParameter(string name)
88
+ {
89
+ return null;
90
+ }
91
+
92
+ /// <summary>
93
+ /// Called at the end of the preprocessing of a source file.
94
+ /// </summary>
95
+ public virtual void Finish()
96
+ {
97
+ }
98
+ }
99
+}
src/WixToolset.Extensibility/ResolvedCabinet.cs
new
+20
@@ -0,0 +1,20 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ /// <summary>
6
+ /// Data returned from build file manager ResolveCabinet callback.
7
+ /// </summary>
8
+ public class ResolvedCabinet
9
+ {
10
+ /// <summary>
11
+ /// Gets or sets the build option for the resolved cabinet.
12
+ /// </summary>
13
+ public CabinetBuildOption BuildOption { get; set; }
14
+
15
+ /// <summary>
16
+ /// Gets or sets the path for the resolved cabinet.
17
+ /// </summary>
18
+ public string Path { get; set; }
19
+ }
20
+}
src/WixToolset.Extensibility/WixToolset.Extensibility.csproj
new
+17
@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<!-- 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. -->
3
+
4
+<Project Sdk="Microsoft.NET.Sdk">
5
+ <PropertyGroup>
6
+ <TargetFramework>netstandard2.0</TargetFramework>
7
+ <Description></Description>
8
+ <Title>WiX Toolset Extensibility</Title>
9
+ </PropertyGroup>
10
+
11
+ <ItemGroup>
12
+ <!-- <ProjectOrPackageReference Include="$(WixToolsetRootFolder)Data\src\WixToolset.Data\WixToolset.Data.csproj" Version="4.0.*" /> -->
13
+ <!--<ProjectOrPackageReference Include="WixToolset.Data" Repo="Data" Version="1.0.*" />-->
14
+ <ProjectReference Include="$(WixToolsetRootFolder)\Data\src\WixToolset.Data\WixToolset.Data.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Data\src\WixToolset.Data\WixToolset.Data.csproj') " />
15
+ <PackageReference Include="WixToolset.Data" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Data\src\WixToolset.Data\WixToolset.Data.csproj') " />
16
+ </ItemGroup>
17
+</Project>