From 404f34f00ecce034a8a06fe4757789c6ce62f3f6 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 14 Nov 2017 23:08:24 -0800 Subject: Remove ICompilerCore, introduce IParseHelper and other small fixes --- .../BaseCompilerExtension.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/WixToolset.Extensibility/BaseCompilerExtension.cs (limited to 'src/WixToolset.Extensibility/BaseCompilerExtension.cs') diff --git a/src/WixToolset.Extensibility/BaseCompilerExtension.cs b/src/WixToolset.Extensibility/BaseCompilerExtension.cs new file mode 100644 index 00000000..508886d3 --- /dev/null +++ b/src/WixToolset.Extensibility/BaseCompilerExtension.cs @@ -0,0 +1,76 @@ +// 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 +{ + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a compiler extension. + /// + public abstract class BaseCompilerExtension : ICompilerExtension + { + /// + /// ParserHelper for use by the extension. + /// + protected IParseHelper ParseHelper { get; private set; } + + /// + /// Gets the schema namespace for this extension. + /// + /// Schema namespace supported by this extension. + public XNamespace Namespace { get; protected set; } + + /// + /// Called at the beginning of the compilation of a source file. + /// + public virtual void PreCompile(ICompileContext context) + { + this.ParseHelper = context.ServiceProvider.GetService(); + } + + /// + /// Processes an attribute for the Compiler. + /// + /// Parent element of attribute. + /// Attribute to process. + /// Extra information about the context in which this element is being parsed. + public virtual void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context) + { + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); + } + + /// + /// Processes an element for the Compiler. + /// + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public virtual void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + this.ParseHelper.UnexpectedElement(parentElement, element); + } + + /// + /// Processes an element for the Compiler, with the ability to supply a component keypath. + /// + /// Parent element of element to process. + /// Element to process. + /// Explicit key path. + /// Extra information about the context in which this element is being parsed. + public virtual ComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + this.ParseElement(intermediate, section, parentElement, element, context); + return null; + } + + /// + /// Called at the end of the compilation of a source file. + /// + public virtual void PostCompile(Intermediate intermediate) + { + } + } +} -- cgit v1.2.3-55-g6feb