@joebigelow / wix-1 / commits / 5287c9ce

Introduce IResolveExtension and IFileSystemExtension with cleanup

Rob Mensching committed Dec 21, 2017 at 13:37 UTC 5287c9ce70877b6b1e96d3253a395101fe30de8f
19 files changed +254 -188
src/WixToolset.Extensibility/BaseResolverExtension.cs new
+38
@@ -0,0 +1,38 @@
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 + using WixToolset.Data.Bind;
7 +
8 + /// <summary>
9 + /// Base class for creating a resolver extension.
10 + /// </summary>
11 + public abstract class BaseResolverExtension : IResolverExtension
12 + {
13 + /// <summary>
14 + /// Context for use by the extension.
15 + /// </summary>
16 + protected IResolveContext Context { get; private set; }
17 +
18 + /// <summary>
19 + /// Called at the beginning of the resolving variables and files.
20 + /// </summary>
21 + public virtual void PreResolve(IResolveContext context)
22 + {
23 + this.Context = context;
24 + }
25 +
26 + public virtual string ResolveFile(string source, IntermediateTupleDefinition tupleDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage)
27 + {
28 + return null;
29 + }
30 +
31 + /// <summary>
32 + /// Called at the end of resolve.
33 + /// </summary>
34 + public virtual void PostResolve(ResolveResult result)
35 + {
36 + }
37 + }
38 +}
src/WixToolset.Extensibility/BinderExtensionBase.cs deleted
-55
@@ -1,55 +0,0 @@
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 - using WixToolset.Data.Bind;
7 - using WixToolset.Extensibility.Services;
8 -
9 - public abstract class BinderExtensionBase : IBinderExtension
10 - {
11 - protected IBindContext Context { get; private set; }
12 -
13 - /// <summary>
14 - /// Called before binding occurs.
15 - /// </summary>
16 - public virtual void PreBind(IBindContext context)
17 - {
18 - this.Context = context;
19 - }
20 -
21 - /// <summary>
22 - /// Called after variable resolution occurs.
23 - /// </summary>
24 - public virtual void AfterResolvedFields(Intermediate intermediate)
25 - {
26 - }
27 -
28 - public virtual string ResolveFile(string source, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage)
29 - {
30 - return null;
31 - }
32 -
33 - public virtual bool? CompareFiles(string targetFile, string updatedFile)
34 - {
35 - return null;
36 - }
37 -
38 - public virtual bool CopyFile(string source, string destination, bool overwrite)
39 - {
40 - return false;
41 - }
42 -
43 - public virtual bool MoveFile(string source, string destination, bool overwrite)
44 - {
45 - return false;
46 - }
47 -
48 - /// <summary>
49 - /// Called after binding is complete before the files are moved to their final locations.
50 - /// </summary>
51 - public virtual void PostBind(BindResult result)
52 - {
53 - }
54 - }
55 -}
src/WixToolset.Extensibility/IBackend.cs
-1
@@ -4,7 +4,6 @@ namespace WixToolset.Extensibility
4 {
5 using WixToolset.Data;
6 using WixToolset.Data.Bind;
7 - using WixToolset.Extensibility.Services;
7
8 public interface IBackend
9 {
src/WixToolset.Extensibility/IBindContext.cs renamed
+3 -10
@@ -1,10 +1,11 @@
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.Services
3 +namespace WixToolset.Extensibility
4 {
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Data;
8 + using WixToolset.Extensibility.Services;
9
10 public interface IBindContext
11 {
@@ -12,8 +13,6 @@ namespace WixToolset.Extensibility.Services
13
14 IMessaging Messaging { get; set; }
15
15 - IEnumerable<BindPath> BindPaths { get; set; }
16 -
16 int CabbingThreadCount { get; set; }
17
18 string CabCachePath { get; set; }
@@ -26,9 +25,7 @@ namespace WixToolset.Extensibility.Services
25
26 IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; }
27
29 - IExtensionManager ExtensionManager { get; set; }
30 -
31 - IEnumerable<IBinderExtension> Extensions { get; set; }
28 + IEnumerable<IFileSystemExtension> FileSystemExtensions { get; set; }
29
30 IEnumerable<string> Ices { get; set; }
31
@@ -40,14 +37,10 @@ namespace WixToolset.Extensibility.Services
37
38 string OutputPdbPath { get; set; }
39
43 - bool SuppressAclReset { get; set; }
44 -
40 IEnumerable<string> SuppressIces { get; set; }
41
42 bool SuppressValidation { get; set; }
43
49 - IBindVariableResolver WixVariableResolver { get; set; }
50 -
44 string ContentsFile { get; set; }
45
46 string OutputsFile { get; set; }
src/WixToolset.Extensibility/IBindVariableResolver.cs deleted
-26
@@ -1,26 +0,0 @@
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 - using WixToolset.Data.Tuples;
7 -
8 - public interface IBindVariableResolver
9 - {
10 - int VariableCount { get; }
11 -
12 - void AddVariable(string name, string value);
13 -
14 - void AddVariable(WixVariableTuple wixVariableRow);
15 -
16 - string ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly);
17 -
18 - string ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, bool errorOnUnknown, out bool isDefault, out bool delayedResolve);
19 -
20 - string ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, out bool isDefault);
21 -
22 - string ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, out bool isDefault, out bool delayedResolve);
23 -
24 - bool TryGetLocalizedControl(string dialog, string control, out LocalizedControl localizedControl);
25 - }
26 -}
src/WixToolset.Extensibility/IBinderExtension.cs deleted
-37
@@ -1,37 +0,0 @@
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 - using WixToolset.Data.Bind;
7 - using WixToolset.Extensibility.Services;
8 -
9 - /// <summary>
10 - /// Interface all binder extensions implement.
11 - /// </summary>
12 - public interface IBinderExtension
13 - {
14 - /// <summary>
15 - /// Called before binding occurs.
16 - /// </summary>
17 - void PreBind(IBindContext context);
18 -
19 - /// <summary>
20 - /// Called after variable resolution occurs.
21 - /// </summary>
22 - void AfterResolvedFields(Intermediate intermediate);
23 -
24 - string ResolveFile(string source, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage);
25 -
26 - bool? CompareFiles(string targetFile, string updatedFile);
27 -
28 - bool CopyFile(string source, string destination, bool overwrite);
29 -
30 - bool MoveFile(string source, string destination, bool overwrite);
31 -
32 - /// <summary>
33 - /// Called after all output changes occur and right before the output is bound into its final format.
34 - /// </summary>
35 - void PostBind(BindResult result);
36 - }
37 -}
src/WixToolset.Extensibility/IBinderFileManagerCore.cs deleted
-55
@@ -1,55 +0,0 @@
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.Bind;
8 -
9 - public interface IBinderFileManagerCore
10 - {
11 - /// <summary>
12 - /// Gets or sets the path to cabinet cache.
13 - /// </summary>
14 - /// <value>The path to cabinet cache.</value>
15 - string CabCachePath { get; }
16 -
17 - /// <summary>
18 - /// Gets or sets the active subStorage used for binding.
19 - /// </summary>
20 - /// <value>The subStorage object.</value>
21 - //SubStorage ActiveSubStorage { get; }
22 -
23 - /// <summary>
24 - /// Gets or sets the output object used for binding.
25 - /// </summary>
26 - /// <value>The output object.</value>
27 - Intermediate Intermediate { get; }
28 -
29 - /// <summary>
30 - /// Gets or sets the path to the temp files location.
31 - /// </summary>
32 - /// <value>The path to the temp files location.</value>
33 - string TempFilesLocation { get; }
34 -
35 - /// <summary>
36 - /// Gets the property if re-basing target is true or false
37 - /// </summary>
38 - /// <value>It returns true if target bind path is to be replaced, otherwise false.</value>
39 - bool RebaseTarget { get; }
40 -
41 - /// <summary>
42 - /// Gets the property if re-basing updated build is true or false
43 - /// </summary>
44 - /// <value>It returns true if updated bind path is to be replaced, otherwise false.</value>
45 - bool RebaseUpdated { get; }
46 -
47 - /// <summary>
48 - /// Gets the collection of paths to locate files during ResolveFile for the provided BindStage and name.
49 - /// </summary>
50 - /// <param name="stage">Optional stage to get bind paths for. Default is normal.</param>
51 - /// <param name="name">Optional name of the bind paths to get. Default is the unnamed paths.</param>
52 - /// <value>The bind paths to locate files.</value>
53 - IEnumerable<string> GetBindPaths(BindStage stage = BindStage.Normal, string name = null);
54 - }
55 -}
src/WixToolset.Extensibility/IFileSystemContext.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 + using System;
6 + using WixToolset.Data;
7 + using WixToolset.Extensibility.Services;
8 +
9 + public interface IFileSystemContext
10 + {
11 + IServiceProvider ServiceProvider { get; }
12 +
13 + IMessaging Messaging { get; set; }
14 +
15 + string CabCachePath { get; set; }
16 +
17 + string IntermediateFolder { get; set; }
18 +
19 + Intermediate IntermediateRepresentation { get; set; }
20 +
21 + string OutputPath { get; set; }
22 +
23 + string OutputPdbPath { get; set; }
24 + }
25 +}
src/WixToolset.Extensibility/IFileSystemExtension.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 + /// <summary>
6 + /// Interface all file system extensions implement.
7 + /// </summary>
8 + public interface IFileSystemExtension
9 + {
10 + void Initialize(IFileSystemContext context);
11 +
12 + bool? CompareFiles(string targetFile, string updatedFile);
13 +
14 + bool CopyFile(string source, string destination, bool overwrite);
15 +
16 + bool MoveFile(string source, string destination, bool overwrite);
17 + }
18 +}
src/WixToolset.Extensibility/ILayoutContext.cs new
+34
@@ -0,0 +1,34 @@
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.Generic;
7 + using WixToolset.Data.Bind;
8 + using WixToolset.Extensibility.Services;
9 +
10 + public interface ILayoutContext
11 + {
12 + IServiceProvider ServiceProvider { get; }
13 +
14 + IMessaging Messaging { get; set; }
15 +
16 + IEnumerable<ILayoutExtension> Extensions { get; set; }
17 +
18 + IEnumerable<IFileSystemExtension> FileSystemExtensions { get; set; }
19 +
20 + IEnumerable<string> ContentFilePaths { get; set; }
21 +
22 + IEnumerable<FileTransfer> FileTransfers { get; set; }
23 +
24 + string OutputPdbPath { get; set; }
25 +
26 + string ContentsFile { get; set; }
27 +
28 + string OutputsFile { get; set; }
29 +
30 + string BuiltOutputsFile { get; set; }
31 +
32 + bool SuppressAclReset { get; set; }
33 + }
34 +}
src/WixToolset.Extensibility/ILayoutExtension.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 + /// Interface all resolver extensions implement.
7 + /// </summary>
8 + public interface ILayoutExtension
9 + {
10 + /// <summary>
11 + /// Called before resolving occurs.
12 + /// </summary>
13 + void PreLayout(ILayoutContext context);
14 +
15 + /// <summary>
16 + /// Called after all resolving occurs.
17 + /// </summary>
18 + void PostLayout();
19 + }
20 +}
src/WixToolset.Extensibility/ILibrarianExtension.cs
+1 -1
@@ -8,7 +8,7 @@ namespace WixToolset.Extensibility
8 {
9 void PreCombine(ILibraryContext context);
10
11 - string Resolve(SourceLineNumber sourceLineNumber, string table, string path);
11 + string Resolve(SourceLineNumber sourceLineNumber, IntermediateTupleDefinition tupleDefinition, string path);
12
13 void PostCombine(Intermediate library);
14 }
src/WixToolset.Extensibility/ILibraryContext.cs
-2
@@ -24,7 +24,5 @@ namespace WixToolset.Extensibility
24 IEnumerable<Localization> Localizations { get; set; }
25
26 IEnumerable<Intermediate> Intermediates { get; set; }
27 -
28 - IBindVariableResolver WixVariableResolver { get; set; }
27 }
28 }
src/WixToolset.Extensibility/ILinkContext.cs renamed
+2 -1
@@ -1,10 +1,11 @@
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.Services
3 +namespace WixToolset.Extensibility
4 {
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Data;
8 + using WixToolset.Extensibility.Services;
9
10 public interface ILinkContext
11 {
src/WixToolset.Extensibility/IResolveContext.cs new
+26
@@ -0,0 +1,26 @@
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.Generic;
7 + using WixToolset.Data;
8 + using WixToolset.Extensibility.Services;
9 +
10 + public interface IResolveContext
11 + {
12 + IServiceProvider ServiceProvider { get; }
13 +
14 + IMessaging Messaging { get; set; }
15 +
16 + IEnumerable<BindPath> BindPaths { get; set; }
17 +
18 + IEnumerable<IResolverExtension> Extensions { get; set; }
19 +
20 + string IntermediateFolder { get; set; }
21 +
22 + Intermediate IntermediateRepresentation { get; set; }
23 +
24 + IBindVariableResolver WixVariableResolver { get; set; }
25 + }
26 +}
src/WixToolset.Extensibility/IResolverExtension.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 + using WixToolset.Data;
6 + using WixToolset.Data.Bind;
7 +
8 + /// <summary>
9 + /// Interface all resolver extensions implement.
10 + /// </summary>
11 + public interface IResolverExtension
12 + {
13 + /// <summary>
14 + /// Called before resolving occurs.
15 + /// </summary>
16 + void PreResolve(IResolveContext context);
17 +
18 + string ResolveFile(string source, IntermediateTupleDefinition tupleDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage);
19 +
20 + /// <summary>
21 + /// Called after all resolving occurs.
22 + /// </summary>
23 + void PostResolve(ResolveResult result);
24 + }
25 +}
src/WixToolset.Extensibility/ResolveResult.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.Collections.Generic;
6 + using WixToolset.Data;
7 +
8 + public class ResolveResult
9 + {
10 + public int Codepage { get; set; }
11 +
12 + public IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; }
13 +
14 + public IEnumerable<IDelayedField> DelayedFields { get; set; }
15 +
16 + public Intermediate IntermediateRepresentation { get; set; }
17 + }
18 +}
\ No newline at end of file
src/WixToolset.Extensibility/Services/BindVariableResolution.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.Services
4 +{
5 + public class BindVariableResolution
6 + {
7 + /// <summary>
8 + /// Indicates whether the variable should be delay resolved.
9 + /// </summary>
10 + public bool DelayedResolve { get; set; }
11 +
12 + /// <summary>
13 + /// Indicates whether the value is the default value of the variable.
14 + /// </summary>
15 + public bool IsDefault { get; set; }
16 +
17 + /// <summary>
18 + /// Indicates whether the value changed.
19 + /// </summary>
20 + public bool UpdatedValue { get; set; }
21 +
22 + /// <summary>
23 + /// Resolved value.
24 + /// </summary>
25 + public string Value { get; set; }
26 + }
27 +}
\ No newline at end of file
src/WixToolset.Extensibility/Services/IBindVariableResolver.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.Services
4 +{
5 + using WixToolset.Data;
6 +
7 + public interface IBindVariableResolver
8 + {
9 + int VariableCount { get; }
10 +
11 + void AddVariable(string name, string value, bool overridable);
12 +
13 + BindVariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly);
14 +
15 + bool TryGetLocalizedControl(string dialog, string control, out LocalizedControl localizedControl);
16 + }
17 +}