public static SolCodeGenResults Generate(CommandArgs appArgs, bool returnFullSources = false) { Stopwatch sw = new Stopwatch(); sw.Start(); var isGenerateAssemblyEnabled = appArgs.Generate.HasFlag(GenerateOutputType.Assembly); var generator = new CodebaseGenerator(appArgs, returnFullSources | isGenerateAssemblyEnabled); generator.GenerateSources(); if (isGenerateAssemblyEnabled) { generator.GenerateCompilationOutput(); } sw.Stop(); Console.WriteLine($"SolCodeGen completed in: {Math.Round(sw.Elapsed.TotalSeconds, 2)} seconds"); return(generator._genResults); }
// MSBuild error/warning stderr formatting // https://blogs.msdn.microsoft.com/msbuild/2006/11/02/msbuild-visual-studio-aware-error-messages-and-message-formats/ // https://stackoverflow.com/a/48117947/794962 // Main.cs(17,20):Command line warning CS0168: The variable 'foo' is declared but never used // -------------- ------------ ------- ------ ---------------------------------------------- // Origin SubCategory Cat. Code Text public static int Main(params string[] args) { CommandArgs appArgs = null; Exception parseException = null; if (!CommandArgs.TryParse(args, out appArgs, out parseException)) { if (parseException.Data.Contains(CommandArgs.MISSING_SOL_FILES)) { Console.Error.WriteLine("Solidity compiler warning MEADOW1008: No .sol files found in the 'contracts' solidity source directory."); return(0); } else { Console.Error.WriteLine($"SolCodeGen:Command arguments error MEADOW1009: {parseException.Message} (see full build output for more details)"); return(0); } } try { var sw = new Stopwatch(); sw.Start(); CodebaseGenerator.Generate(appArgs); sw.Stop(); Console.WriteLine($"Solidity analysis and code generation process took: {Math.Round(sw.Elapsed.TotalSeconds, 2)} seconds"); } catch (Exception ex) { Console.WriteLine(ex); IEnumerable <CompilerException> compilerExceptions = null; if (ex is AggregateException aggr && aggr.InnerException is CompilerException) { compilerExceptions = aggr.InnerExceptions.OfType <CompilerException>(); }