public void SmartContract_Compiler_CanCompileMultipleFiles() { ContractCompilationResult result = ContractCompiler.CompileDirectory("SmartContracts", "MultipleFiles"); Assert.True(result.Success); IContractModuleDefinition decomp = ContractDecompiler.GetModuleDefinition(result.Compilation).Value; Assert.Contains(decomp.ModuleDefinition.Types, x => x.Name == "MultipleFiles1"); Assert.Contains(decomp.ModuleDefinition.Types, x => x.Name == "MultipleFiles2"); }
/// <summary> /// Compile a file or directory, returning a ContractCompilationResult. /// </summary> /// <returns>ContractCompilationResult if the file exists, and null otherwise.</returns> public static ContractCompilationResult CompileFromFileOrDirectoryName(string fileOrDirectoryName, IConsole console = null) { if (File.Exists(fileOrDirectoryName)) { console?.WriteLine($"Compiling {fileOrDirectoryName}..."); return(ContractCompiler.CompileFile(fileOrDirectoryName)); } if (Directory.Exists(fileOrDirectoryName)) { console?.WriteLine($"Compiling directory {fileOrDirectoryName}..."); return(ContractCompiler.CompileDirectory(fileOrDirectoryName)); } // TODO: Ideally this guy would return a ContractCompilationResult too but dealing with Diagnostics is a nightmare. This works for now. console?.WriteLine($"No file or directory {fileOrDirectoryName} exists."); return(null); }