From 1d6ff8af3c423ee4622185edc986ae5caad6b122 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 26 Dec 2017 15:11:40 -0800 Subject: Standardize creation of public objects in move towards interfaces --- src/WixToolset.Core/CommandLine/CompileCommand.cs | 42 +++++++---------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'src/WixToolset.Core/CommandLine/CompileCommand.cs') diff --git a/src/WixToolset.Core/CommandLine/CompileCommand.cs b/src/WixToolset.Core/CommandLine/CompileCommand.cs index f0ff5b1a..123318f5 100644 --- a/src/WixToolset.Core/CommandLine/CompileCommand.cs +++ b/src/WixToolset.Core/CommandLine/CompileCommand.cs @@ -4,28 +4,21 @@ namespace WixToolset.Core.CommandLine { using System; using System.Collections.Generic; - using System.Linq; using WixToolset.Data; using WixToolset.Extensibility; using WixToolset.Extensibility.Services; internal class CompileCommand : ICommandLineCommand { - public CompileCommand(IServiceProvider serviceProvider, IMessaging messaging, IExtensionManager extensions, IEnumerable sources, IDictionary preprocessorVariables) + public CompileCommand(IServiceProvider serviceProvider, IEnumerable sources, IDictionary preprocessorVariables) { this.PreprocessorVariables = preprocessorVariables; this.ServiceProvider = serviceProvider; - this.Messaging = messaging; - this.ExtensionManager = extensions; this.SourceFiles = sources; } private IServiceProvider ServiceProvider { get; } - private IMessaging Messaging { get; } - - private IExtensionManager ExtensionManager { get; } - public IEnumerable IncludeSearchPaths { get; } private IEnumerable SourceFiles { get; } @@ -36,27 +29,18 @@ namespace WixToolset.Core.CommandLine { foreach (var sourceFile in this.SourceFiles) { - var preprocessContext = this.ServiceProvider.GetService(); - preprocessContext.Messaging = this.Messaging; - preprocessContext.Extensions = this.ExtensionManager.Create(); - preprocessContext.Platform = Platform.X86; // TODO: set this correctly - preprocessContext.IncludeSearchPaths = this.IncludeSearchPaths?.ToList() ?? new List(); - preprocessContext.SourceFile = sourceFile.SourcePath; - preprocessContext.Variables = new Dictionary(this.PreprocessorVariables); - - var preprocessor = new Preprocessor(); - var document = preprocessor.Process(preprocessContext); - - var compileContext = this.ServiceProvider.GetService(); - compileContext.Messaging = this.Messaging; - compileContext.CompilationId = Guid.NewGuid().ToString("N"); - compileContext.Extensions = this.ExtensionManager.Create(); - compileContext.OutputPath = sourceFile.OutputPath; - compileContext.Platform = Platform.X86; // TODO: set this correctly - compileContext.Source = document; - - var compiler = new Compiler(); - var intermediate = compiler.Compile(compileContext); + var preprocessor = new Preprocessor(this.ServiceProvider); + preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; + preprocessor.Platform = Platform.X86; // TODO: set this correctly + preprocessor.SourcePath = sourceFile.SourcePath; + preprocessor.Variables = new Dictionary(this.PreprocessorVariables); + var document = preprocessor.Execute(); + + var compiler = new Compiler(this.ServiceProvider); + compiler.OutputPath = sourceFile.OutputPath; + compiler.Platform = Platform.X86; // TODO: set this correctly + compiler.SourceDocument = document; + var intermediate = compiler.Execute(); intermediate.Save(sourceFile.OutputPath); } -- cgit v1.2.3-55-g6feb