diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-02 00:45:33 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-02 00:45:33 -0800 |
| commit | fb2df0e24c0709ce94c396624cf86c70e02da01f (patch) | |
| tree | e0a16a342dca4f9b343afa945d89116856950b83 /src | |
| parent | 404f34f00ecce034a8a06fe4757789c6ce62f3f6 (diff) | |
| download | wix-fb2df0e24c0709ce94c396624cf86c70e02da01f.tar.gz wix-fb2df0e24c0709ce94c396624cf86c70e02da01f.tar.bz2 wix-fb2df0e24c0709ce94c396624cf86c70e02da01f.zip | |
Fix IExtensionCommandLine and IPreprocessorExtension
Diffstat (limited to 'src')
| -rw-r--r-- | src/Directory.Build.props | 4 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/BaseCompilerExtension.cs | 7 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/BasePreprocessorExtension.cs (renamed from src/WixToolset.Extensibility/PreprocessorExtension.cs) | 47 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/IExtensionCommandLine.cs | 17 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/IExtensionData.cs | 4 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/IPreprocessContext.cs | 31 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/IPreprocessorCore.cs | 21 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/IPreprocessorExtension.cs | 26 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/Services/IParseCommandLine.cs | 21 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/Services/IParseHelper.cs | 9 | ||||
| -rw-r--r-- | src/WixToolset.Extensibility/Services/IPreprocessHelper.cs | 89 |
11 files changed, 184 insertions, 92 deletions
diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 25cb6d36..7cd6767f 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props | |||
| @@ -5,11 +5,13 @@ | |||
| 5 | <PropertyGroup> | 5 | <PropertyGroup> |
| 6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | 6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
| 7 | <BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath> | 7 | <BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath> |
| 8 | <OutputPath>$(MSBuildThisFileDirectory)..\build\$(Configuration)\</OutputPath> | 8 | <BaseOutputPath>$(MSBuildThisFileDirectory)..\build\$(Configuration)\</BaseOutputPath> |
| 9 | <OutputPath>$(BaseOutputPath)</OutputPath> | ||
| 9 | 10 | ||
| 10 | <Authors>WiX Toolset Team</Authors> | 11 | <Authors>WiX Toolset Team</Authors> |
| 11 | <Company>WiX Toolset</Company> | 12 | <Company>WiX Toolset</Company> |
| 12 | <Copyright>Copyright (c) .NET Foundation and contributors. All rights reserved.</Copyright> | 13 | <Copyright>Copyright (c) .NET Foundation and contributors. All rights reserved.</Copyright> |
| 14 | <Product>WiX Toolset</Product> | ||
| 13 | </PropertyGroup> | 15 | </PropertyGroup> |
| 14 | 16 | ||
| 15 | <PropertyGroup> | 17 | <PropertyGroup> |
diff --git a/src/WixToolset.Extensibility/BaseCompilerExtension.cs b/src/WixToolset.Extensibility/BaseCompilerExtension.cs index 508886d3..5dfe5dcf 100644 --- a/src/WixToolset.Extensibility/BaseCompilerExtension.cs +++ b/src/WixToolset.Extensibility/BaseCompilerExtension.cs | |||
| @@ -13,6 +13,11 @@ namespace WixToolset.Extensibility | |||
| 13 | public abstract class BaseCompilerExtension : ICompilerExtension | 13 | public abstract class BaseCompilerExtension : ICompilerExtension |
| 14 | { | 14 | { |
| 15 | /// <summary> | 15 | /// <summary> |
| 16 | /// Messaging for use by the extension. | ||
| 17 | /// </summary> | ||
| 18 | protected Messaging Messaging { get; private set; } | ||
| 19 | |||
| 20 | /// <summary> | ||
| 16 | /// ParserHelper for use by the extension. | 21 | /// ParserHelper for use by the extension. |
| 17 | /// </summary> | 22 | /// </summary> |
| 18 | protected IParseHelper ParseHelper { get; private set; } | 23 | protected IParseHelper ParseHelper { get; private set; } |
| @@ -28,6 +33,8 @@ namespace WixToolset.Extensibility | |||
| 28 | /// </summary> | 33 | /// </summary> |
| 29 | public virtual void PreCompile(ICompileContext context) | 34 | public virtual void PreCompile(ICompileContext context) |
| 30 | { | 35 | { |
| 36 | this.Messaging = context.Messaging; | ||
| 37 | |||
| 31 | this.ParseHelper = context.ServiceProvider.GetService<IParseHelper>(); | 38 | this.ParseHelper = context.ServiceProvider.GetService<IParseHelper>(); |
| 32 | } | 39 | } |
| 33 | 40 | ||
diff --git a/src/WixToolset.Extensibility/PreprocessorExtension.cs b/src/WixToolset.Extensibility/BasePreprocessorExtension.cs index 2af30a95..acfcd5b9 100644 --- a/src/WixToolset.Extensibility/PreprocessorExtension.cs +++ b/src/WixToolset.Extensibility/BasePreprocessorExtension.cs | |||
| @@ -3,33 +3,37 @@ | |||
| 3 | namespace WixToolset.Extensibility | 3 | namespace WixToolset.Extensibility |
| 4 | { | 4 | { |
| 5 | using System.Xml.Linq; | 5 | using System.Xml.Linq; |
| 6 | using WixToolset.Data; | 6 | using WixToolset.Extensibility.Services; |
| 7 | 7 | ||
| 8 | /// <summary> | 8 | /// <summary> |
| 9 | /// Base class for creating a preprocessor extension. | 9 | /// Base class for creating a preprocessor extension. |
| 10 | /// </summary> | 10 | /// </summary> |
| 11 | public abstract class PreprocessorExtension : IPreprocessorExtension | 11 | public abstract class BasePreprocessorExtension : IPreprocessorExtension |
| 12 | { | 12 | { |
| 13 | /// <summary> | 13 | /// <summary> |
| 14 | /// Gets or sets the preprocessor core for the extension. | 14 | /// Context for use by the extension. |
| 15 | /// </summary> | 15 | /// </summary> |
| 16 | /// <value>Preprocessor core for the extension.</value> | 16 | protected IPreprocessContext Context { get; private set; } |
| 17 | public IPreprocessorCore Core { get; set; } | 17 | |
| 18 | /// <summary> | ||
| 19 | /// ParserHelper for use by the extension. | ||
| 20 | /// </summary> | ||
| 21 | protected IPreprocessHelper PreprocessHelper { get; private set; } | ||
| 18 | 22 | ||
| 19 | /// <summary> | 23 | /// <summary> |
| 20 | /// Gets or sets the variable prefixes for the extension. | 24 | /// Gets or sets the variable prefixes for the extension. |
| 21 | /// </summary> | 25 | /// </summary> |
| 22 | /// <value>The variable prefixes for the extension.</value> | 26 | /// <value>The variable prefixes for the extension.</value> |
| 23 | public virtual string[] Prefixes | 27 | public string[] Prefixes { get; protected set; } |
| 24 | { | ||
| 25 | get { return null; } | ||
| 26 | } | ||
| 27 | 28 | ||
| 28 | /// <summary> | 29 | /// <summary> |
| 29 | /// Called at the beginning of the preprocessing of a source file. | 30 | /// Called at the beginning of the preprocessing of a source file. |
| 30 | /// </summary> | 31 | /// </summary> |
| 31 | public virtual void Initialize() | 32 | public virtual void PrePreprocess(IPreprocessContext context) |
| 32 | { | 33 | { |
| 34 | this.Context = context; | ||
| 35 | |||
| 36 | this.PreprocessHelper = context.ServiceProvider.GetService<IPreprocessHelper>(); | ||
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | /// <summary> | 39 | /// <summary> |
| @@ -65,34 +69,15 @@ namespace WixToolset.Extensibility | |||
| 65 | /// <param name="parent">The parent node of the pragma.</param> | 69 | /// <param name="parent">The parent node of the pragma.</param> |
| 66 | /// <returns>false if the pragma is not defined.</returns> | 70 | /// <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> | 71 | /// <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) | 72 | public virtual bool ProcessPragma(string prefix, string pragma, string args, XContainer parent) |
| 69 | { | 73 | { |
| 70 | return false; | 74 | return false; |
| 71 | } | 75 | } |
| 72 | 76 | ||
| 73 | /// <summary> | 77 | /// <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. | 78 | /// Called at the end of the preprocessing of a source file. |
| 94 | /// </summary> | 79 | /// </summary> |
| 95 | public virtual void Finish() | 80 | public virtual void PostPreprocess(XDocument document) |
| 96 | { | 81 | { |
| 97 | } | 82 | } |
| 98 | } | 83 | } |
diff --git a/src/WixToolset.Extensibility/IExtensionCommandLine.cs b/src/WixToolset.Extensibility/IExtensionCommandLine.cs index b6cff5d0..1f8e6ed8 100644 --- a/src/WixToolset.Extensibility/IExtensionCommandLine.cs +++ b/src/WixToolset.Extensibility/IExtensionCommandLine.cs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | namespace WixToolset.Extensibility | 3 | namespace WixToolset.Extensibility |
| 4 | { | 4 | { |
| 5 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
| 6 | using WixToolset.Data; | 6 | using WixToolset.Extensibility.Services; |
| 7 | 7 | ||
| 8 | /// <summary> | 8 | /// <summary> |
| 9 | /// A command line option. | 9 | /// A command line option. |
| @@ -21,22 +21,13 @@ namespace WixToolset.Extensibility | |||
| 21 | public interface IExtensionCommandLine | 21 | public interface IExtensionCommandLine |
| 22 | { | 22 | { |
| 23 | /// <summary> | 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. | 24 | /// Gets the supported command line types for this extension. |
| 31 | /// </summary> | 25 | /// </summary> |
| 32 | /// <value>The supported command line types for this extension.</value> | 26 | /// <value>The supported command line types for this extension.</value> |
| 33 | IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches { get; } | 27 | IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches { get; } |
| 34 | 28 | ||
| 35 | /// <summary> | 29 | void PreParse(ICommandLineContext context); |
| 36 | /// Parse the commandline arguments. | 30 | |
| 37 | /// </summary> | 31 | bool TryParseArgument(IParseCommandLine parseCommandLine, string arg); |
| 38 | /// <param name="args">Commandline arguments.</param> | ||
| 39 | /// <returns>Unparsed commandline arguments.</returns> | ||
| 40 | string[] ParseCommandLine(string[] args); | ||
| 41 | } | 32 | } |
| 42 | } | 33 | } |
diff --git a/src/WixToolset.Extensibility/IExtensionData.cs b/src/WixToolset.Extensibility/IExtensionData.cs index f0e339d4..1721a76c 100644 --- a/src/WixToolset.Extensibility/IExtensionData.cs +++ b/src/WixToolset.Extensibility/IExtensionData.cs | |||
| @@ -26,8 +26,8 @@ namespace WixToolset.Extensibility | |||
| 26 | /// <summary> | 26 | /// <summary> |
| 27 | /// Gets the library associated with this extension. | 27 | /// Gets the library associated with this extension. |
| 28 | /// </summary> | 28 | /// </summary> |
| 29 | /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> | 29 | /// <param name="tupleDefinitions">The tuple definitions to use while loading the library.</param> |
| 30 | /// <returns>The library for this extension or null if there is no library.</returns> | 30 | /// <returns>The library for this extension or null if there is no library.</returns> |
| 31 | Library GetLibrary(ITupleDefinitionCreator tupleDefinitions); | 31 | Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions); |
| 32 | } | 32 | } |
| 33 | } | 33 | } |
diff --git a/src/WixToolset.Extensibility/IPreprocessContext.cs b/src/WixToolset.Extensibility/IPreprocessContext.cs new file mode 100644 index 00000000..0f9c90bf --- /dev/null +++ b/src/WixToolset.Extensibility/IPreprocessContext.cs | |||
| @@ -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 System.Collections.Generic; | ||
| 7 | using WixToolset.Data; | ||
| 8 | |||
| 9 | public interface IPreprocessContext | ||
| 10 | { | ||
| 11 | IServiceProvider ServiceProvider { get; } | ||
| 12 | |||
| 13 | Messaging Messaging { get; set; } | ||
| 14 | |||
| 15 | IEnumerable<IPreprocessorExtension> Extensions { get; set; } | ||
| 16 | |||
| 17 | /// <summary> | ||
| 18 | /// Gets the platform which the compiler will use when defaulting 64-bit attributes and elements. | ||
| 19 | /// </summary> | ||
| 20 | /// <value>The platform which the compiler will use when defaulting 64-bit attributes and elements.</value> | ||
| 21 | Platform Platform { get; set; } | ||
| 22 | |||
| 23 | IList<string> IncludeSearchPaths { get; set; } | ||
| 24 | |||
| 25 | string SourceFile { get; set; } | ||
| 26 | |||
| 27 | IDictionary<string, string> Variables { get; set; } | ||
| 28 | |||
| 29 | SourceLineNumber CurrentSourceLineNumber { get; set; } | ||
| 30 | } | ||
| 31 | } | ||
diff --git a/src/WixToolset.Extensibility/IPreprocessorCore.cs b/src/WixToolset.Extensibility/IPreprocessorCore.cs deleted file mode 100644 index a0449139..00000000 --- a/src/WixToolset.Extensibility/IPreprocessorCore.cs +++ /dev/null | |||
| @@ -1,21 +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 | |||
| 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 | } | ||
diff --git a/src/WixToolset.Extensibility/IPreprocessorExtension.cs b/src/WixToolset.Extensibility/IPreprocessorExtension.cs index de415526..8511abbc 100644 --- a/src/WixToolset.Extensibility/IPreprocessorExtension.cs +++ b/src/WixToolset.Extensibility/IPreprocessorExtension.cs | |||
| @@ -12,12 +12,6 @@ namespace WixToolset.Extensibility | |||
| 12 | public interface IPreprocessorExtension | 12 | public interface IPreprocessorExtension |
| 13 | { | 13 | { |
| 14 | /// <summary> | 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. | 15 | /// Gets the variable prefixes for the extension. |
| 22 | /// </summary> | 16 | /// </summary> |
| 23 | /// <value>The variable prefixes for the extension.</value> | 17 | /// <value>The variable prefixes for the extension.</value> |
| @@ -26,7 +20,7 @@ namespace WixToolset.Extensibility | |||
| 26 | /// <summary> | 20 | /// <summary> |
| 27 | /// Called at the beginning of the preprocessing of a source file. | 21 | /// Called at the beginning of the preprocessing of a source file. |
| 28 | /// </summary> | 22 | /// </summary> |
| 29 | void Initialize(); | 23 | void PrePreprocess(IPreprocessContext context); |
| 30 | 24 | ||
| 31 | /// <summary> | 25 | /// <summary> |
| 32 | /// Gets the value of a variable whose prefix matches the extension. | 26 | /// Gets the value of a variable whose prefix matches the extension. |
| @@ -55,25 +49,11 @@ namespace WixToolset.Extensibility | |||
| 55 | /// <param name="parent">The parent node of the pragma.</param> | 49 | /// <param name="parent">The parent node of the pragma.</param> |
| 56 | /// <returns>false if the pragma is not defined.</returns> | 50 | /// <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> | 51 | /// <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); | 52 | bool ProcessPragma(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 | 53 | ||
| 74 | /// <summary> | 54 | /// <summary> |
| 75 | /// Called at the end of the preprocessing of a source file. | 55 | /// Called at the end of the preprocessing of a source file. |
| 76 | /// </summary> | 56 | /// </summary> |
| 77 | void Finish(); | 57 | void PostPreprocess(XDocument document); |
| 78 | } | 58 | } |
| 79 | } | 59 | } |
diff --git a/src/WixToolset.Extensibility/Services/IParseCommandLine.cs b/src/WixToolset.Extensibility/Services/IParseCommandLine.cs new file mode 100644 index 00000000..1b23be14 --- /dev/null +++ b/src/WixToolset.Extensibility/Services/IParseCommandLine.cs | |||
| @@ -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.Services | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | |||
| 7 | public interface IParseCommandLine | ||
| 8 | { | ||
| 9 | bool IsSwitch(string arg); | ||
| 10 | |||
| 11 | bool IsSwitchAt(IEnumerable<string> args, int index); | ||
| 12 | |||
| 13 | void GetNextArgumentOrError(ref string arg); | ||
| 14 | |||
| 15 | void GetNextArgumentOrError(IList<string> args); | ||
| 16 | |||
| 17 | void GetNextArgumentAsFilePathOrError(IList<string> args, string fileType); | ||
| 18 | |||
| 19 | bool TryGetNextArgumentOrError(out string arg); | ||
| 20 | } | ||
| 21 | } | ||
diff --git a/src/WixToolset.Extensibility/Services/IParseHelper.cs b/src/WixToolset.Extensibility/Services/IParseHelper.cs index 46ade2e1..ad15c063 100644 --- a/src/WixToolset.Extensibility/Services/IParseHelper.cs +++ b/src/WixToolset.Extensibility/Services/IParseHelper.cs | |||
| @@ -8,7 +8,7 @@ namespace WixToolset.Extensibility.Services | |||
| 8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 9 | 9 | ||
| 10 | /// <summary> | 10 | /// <summary> |
| 11 | /// Core interface provided by the compiler. | 11 | /// Interface provided to help compiler extensions parse. |
| 12 | /// </summary> | 12 | /// </summary> |
| 13 | public interface IParseHelper | 13 | public interface IParseHelper |
| 14 | { | 14 | { |
| @@ -243,6 +243,13 @@ namespace WixToolset.Extensibility.Services | |||
| 243 | YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); | 243 | YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); |
| 244 | 244 | ||
| 245 | /// <summary> | 245 | /// <summary> |
| 246 | /// Gets a source line number for an element. | ||
| 247 | /// </summary> | ||
| 248 | /// <param name="element">Element to get source line number.</param> | ||
| 249 | /// <returns>Source line number.</returns> | ||
| 250 | SourceLineNumber GetSourceLineNumbers(XElement element); | ||
| 251 | |||
| 252 | /// <summary> | ||
| 246 | /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace. | 253 | /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace. |
| 247 | /// </summary> | 254 | /// </summary> |
| 248 | /// <param name="node">The node to ensure inner text is a condition.</param> | 255 | /// <param name="node">The node to ensure inner text is a condition.</param> |
diff --git a/src/WixToolset.Extensibility/Services/IPreprocessHelper.cs b/src/WixToolset.Extensibility/Services/IPreprocessHelper.cs new file mode 100644 index 00000000..01c55009 --- /dev/null +++ b/src/WixToolset.Extensibility/Services/IPreprocessHelper.cs | |||
| @@ -0,0 +1,89 @@ | |||
| 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 System.Xml.Linq; | ||
| 6 | |||
| 7 | /// <summary> | ||
| 8 | /// Interface provided to help preprocessor extensions. | ||
| 9 | /// </summary> | ||
| 10 | public interface IPreprocessHelper | ||
| 11 | { | ||
| 12 | /// <summary> | ||
| 13 | /// Add a variable. | ||
| 14 | /// </summary> | ||
| 15 | /// <param name="context">The preprocess context.</param> | ||
| 16 | /// <param name="name">The variable name.</param> | ||
| 17 | /// <param name="value">The variable value.</param> | ||
| 18 | void AddVariable(IPreprocessContext context, string name, string value); | ||
| 19 | |||
| 20 | /// <summary> | ||
| 21 | /// Add a variable. | ||
| 22 | /// </summary> | ||
| 23 | /// <param name="context">The preprocess context.</param> | ||
| 24 | /// <param name="name">The variable name.</param> | ||
| 25 | /// <param name="value">The variable value.</param> | ||
| 26 | /// <param name="overwrite">Set to true to show variable overwrite warning.</param> | ||
| 27 | void AddVariable(IPreprocessContext context, string name, string value, bool showWarning); | ||
| 28 | |||
| 29 | /// <summary> | ||
| 30 | /// Evaluate a function. | ||
| 31 | /// </summary> | ||
| 32 | /// <param name="context">The preprocess context.</param> | ||
| 33 | /// <param name="function">The function expression including the prefix and name.</param> | ||
| 34 | /// <returns>The function value.</returns> | ||
| 35 | string EvaluateFunction(IPreprocessContext context, string function); | ||
| 36 | |||
| 37 | /// <summary> | ||
| 38 | /// Evaluate a function. | ||
| 39 | /// </summary> | ||
| 40 | /// <param name="context">The preprocess context.</param> | ||
| 41 | /// <param name="prefix">The function prefix.</param> | ||
| 42 | /// <param name="function">The function name.</param> | ||
| 43 | /// <param name="args">The arguments for the function.</param> | ||
| 44 | /// <returns>The function value or null if the function is not defined.</returns> | ||
| 45 | string EvaluateFunction(IPreprocessContext context, string prefix, string function, string[] args); | ||
| 46 | |||
| 47 | /// <summary> | ||
| 48 | /// Get the value of a variable expression like var.name. | ||
| 49 | /// </summary> | ||
| 50 | /// <param name="context">The preprocess context.</param> | ||
| 51 | /// <param name="variable">The variable expression including the optional prefix and name.</param> | ||
| 52 | /// <param name="allowMissingPrefix">true to allow the variable prefix to be missing.</param> | ||
| 53 | /// <returns>The variable value.</returns> | ||
| 54 | string GetVariableValue(IPreprocessContext context, string variable, bool allowMissingPrefix); | ||
| 55 | |||
| 56 | /// <summary> | ||
| 57 | /// Get the value of a variable. | ||
| 58 | /// </summary> | ||
| 59 | /// <param name="context">The preprocess context.</param> | ||
| 60 | /// <param name="prefix">The variable prefix.</param> | ||
| 61 | /// <param name="name">The variable name.</param> | ||
| 62 | /// <returns>The variable value or null if the variable is not set.</returns> | ||
| 63 | string GetVariableValue(IPreprocessContext context, string prefix, string name); | ||
| 64 | |||
| 65 | /// <summary> | ||
| 66 | /// Evaluate a Pragma. | ||
| 67 | /// </summary> | ||
| 68 | /// <param name="context">The preprocess context.</param> | ||
| 69 | /// <param name="pragmaName">The pragma's full name (<prefix>.<pragma>).</param> | ||
| 70 | /// <param name="args">The arguments to the pragma.</param> | ||
| 71 | /// <param name="parent">The parent element of the pragma.</param> | ||
| 72 | void PreprocessPragma(IPreprocessContext context, string pragmaName, string args, XContainer parent); | ||
| 73 | |||
| 74 | /// <summary> | ||
| 75 | /// Replaces parameters in the source text. | ||
| 76 | /// </summary> | ||
| 77 | /// <param name="context">The preprocess context.</param> | ||
| 78 | /// <param name="value">Text that may contain parameters to replace.</param> | ||
| 79 | /// <returns>Text after parameters have been replaced.</returns> | ||
| 80 | string PreprocessString(IPreprocessContext context, string value); | ||
| 81 | |||
| 82 | /// <summary> | ||
| 83 | /// Remove a variable. | ||
| 84 | /// </summary> | ||
| 85 | /// <param name="context">The preprocess context.</param> | ||
| 86 | /// <param name="name">The variable name.</param> | ||
| 87 | void RemoveVariable(IPreprocessContext context, string name); | ||
| 88 | } | ||
| 89 | } | ||
