internal void GenerateCode() { var outputDirectory = Environment.CurrentDirectory; var generatedCodeDirectory = Path.Combine(outputDirectory, "GeneratedCode"); Directory.CreateDirectory(generatedCodeDirectory); var fileDeletionTimer = Stopwatch.StartNew(); foreach (var existingGeneratedFile in Directory.EnumerateFiles(generatedCodeDirectory, filePrefix + "*")) { File.Delete(existingGeneratedFile); } fileDeletionTimer.Stop(); Console.WriteLine("\nTook {0} ({1,8:N2} ms) - to delete existing files from disk\n", fileDeletionTimer.Elapsed, fileDeletionTimer.Elapsed.TotalMilliseconds); var allSyntaxTrees = new List <SyntaxTree>(GenerateEmbeddedCode()); var analyser = new Analyser(); foreach (var file in projectSettings.SourceFiles.Where(f => f.StartsWith("Properties\\") == false)) { Console.WriteLine("Processing file: " + file); var timer = Stopwatch.StartNew(); var filePath = Path.Combine(projectSettings.RootFolder, file); var code = File.ReadAllText(filePath); var benchmarkTree = CSharpSyntaxTree.ParseText(code, options: parseOptions, path: filePath, encoding: defaultEncoding); timer.Stop(); Console.WriteLine("Took {0} ({1,8:N2} ms) - to read existing benchmark and generate CSharp Syntax Tree", timer.Elapsed, timer.Elapsed.TotalMilliseconds); var analysisTimer = Stopwatch.StartNew(); var benchmarkInfo = analyser.AnalyseBenchmark(benchmarkTree, filePrefix); analysisTimer.Stop(); Console.WriteLine("Took {0} ({1,8:N2} ms) - to analyse the benchmark code", analysisTimer.Elapsed, analysisTimer.Elapsed.TotalMilliseconds); allSyntaxTrees.Add(benchmarkTree); var generatedRunners = GenerateRunners(benchmarkInfo, generatedCodeDirectory); allSyntaxTrees.AddRange(generatedRunners); } var generatedLauncher = GenerateLauncher(generatedCodeDirectory); allSyntaxTrees.Add(generatedLauncher); CompileAndEmitCode(allSyntaxTrees); }