public Build Compile(BuildProject buildProject, IEnumerable <Calculation> calculations, CompilerOptions compilerOptions = null) { try { if (compilerOptions == null) { compilerOptions = new CompilerOptions { SpecificationId = buildProject.SpecificationId, OptionStrictEnabled = false }; } IEnumerable <SourceFile> sourceFiles = GenerateSourceFiles(buildProject, calculations, compilerOptions); ICompiler compiler = _compilerFactory.GetCompiler(sourceFiles); return(compiler.GenerateCode(sourceFiles?.ToList(), calculations)); } catch (Exception e) { return(new Build { CompilerMessages = new List <CompilerMessage> { new CompilerMessage { Message = e.Message, Severity = Severity.Error } } }); } }
private static ICompilerFactory CreateCompilerFactory(ICompiler compiler = null, IEnumerable <SourceFile> sourceFiles = null) { ICompilerFactory compilerFactory = Substitute.For <ICompilerFactory>(); compilerFactory .GetCompiler(Arg.Is(sourceFiles)) .Returns(compiler); return(compilerFactory); }