From fb2df0e24c0709ce94c396624cf86c70e02da01f Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 2 Dec 2017 00:45:33 -0800 Subject: Fix IExtensionCommandLine and IPreprocessorExtension --- .../Services/IParseCommandLine.cs | 21 +++++ .../Services/IParseHelper.cs | 9 ++- .../Services/IPreprocessHelper.cs | 89 ++++++++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 src/WixToolset.Extensibility/Services/IParseCommandLine.cs create mode 100644 src/WixToolset.Extensibility/Services/IPreprocessHelper.cs (limited to 'src/WixToolset.Extensibility/Services') 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 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Services +{ + using System.Collections.Generic; + + public interface IParseCommandLine + { + bool IsSwitch(string arg); + + bool IsSwitchAt(IEnumerable args, int index); + + void GetNextArgumentOrError(ref string arg); + + void GetNextArgumentOrError(IList args); + + void GetNextArgumentAsFilePathOrError(IList args, string fileType); + + bool TryGetNextArgumentOrError(out string arg); + } +} 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 using WixToolset.Data; /// - /// Core interface provided by the compiler. + /// Interface provided to help compiler extensions parse. /// public interface IParseHelper { @@ -242,6 +242,13 @@ namespace WixToolset.Extensibility.Services /// The attribute's YesNoType value. YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + /// + /// Gets a source line number for an element. + /// + /// Element to get source line number. + /// Source line number. + SourceLineNumber GetSourceLineNumbers(XElement element); + /// /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace. /// 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 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Services +{ + using System.Xml.Linq; + + /// + /// Interface provided to help preprocessor extensions. + /// + public interface IPreprocessHelper + { + /// + /// Add a variable. + /// + /// The preprocess context. + /// The variable name. + /// The variable value. + void AddVariable(IPreprocessContext context, string name, string value); + + /// + /// Add a variable. + /// + /// The preprocess context. + /// The variable name. + /// The variable value. + /// Set to true to show variable overwrite warning. + void AddVariable(IPreprocessContext context, string name, string value, bool showWarning); + + /// + /// Evaluate a function. + /// + /// The preprocess context. + /// The function expression including the prefix and name. + /// The function value. + string EvaluateFunction(IPreprocessContext context, string function); + + /// + /// Evaluate a function. + /// + /// The preprocess context. + /// The function prefix. + /// The function name. + /// The arguments for the function. + /// The function value or null if the function is not defined. + string EvaluateFunction(IPreprocessContext context, string prefix, string function, string[] args); + + /// + /// Get the value of a variable expression like var.name. + /// + /// The preprocess context. + /// The variable expression including the optional prefix and name. + /// true to allow the variable prefix to be missing. + /// The variable value. + string GetVariableValue(IPreprocessContext context, string variable, bool allowMissingPrefix); + + /// + /// Get the value of a variable. + /// + /// The preprocess context. + /// The variable prefix. + /// The variable name. + /// The variable value or null if the variable is not set. + string GetVariableValue(IPreprocessContext context, string prefix, string name); + + /// + /// Evaluate a Pragma. + /// + /// The preprocess context. + /// The pragma's full name (.). + /// The arguments to the pragma. + /// The parent element of the pragma. + void PreprocessPragma(IPreprocessContext context, string pragmaName, string args, XContainer parent); + + /// + /// Replaces parameters in the source text. + /// + /// The preprocess context. + /// Text that may contain parameters to replace. + /// Text after parameters have been replaced. + string PreprocessString(IPreprocessContext context, string value); + + /// + /// Remove a variable. + /// + /// The preprocess context. + /// The variable name. + void RemoveVariable(IPreprocessContext context, string name); + } +} -- cgit v1.2.3-55-g6feb