public CompilerOutput Compile(string solcPath, string derivedFilePath) { if (!File.Exists(solcPath)) { throw new SystemException($"Cannot find solidity compiler at {solcPath}"); } derivedFilePath = derivedFilePath.Replace("\\", "/"); string jsonString = RunSolc(solcPath, derivedFilePath); List <string> errors = new List <string>(); var settings = new JsonSerializerSettings { Error = (sender, errorArgs) => { errors.Add(errorArgs.ErrorContext.Error.Message); errorArgs.ErrorContext.Handled = true; }, }; CompilerOutput compilerOutput = JsonConvert.DeserializeObject <CompilerOutput>(jsonString); if (errors.Count != 0) { throw new SystemException($"Deserialization of Solidity compiler output failed with errors: {JsonConvert.SerializeObject(errors)}"); } return(compilerOutput); }
public bool Execute(string filename) { string filePath = testDirectory + "\\" + filename; // read the program text string programText = File.ReadAllText(filePath); // get the text of AST traversal SolidityCompiler compiler = new SolidityCompiler(); CompilerOutput compilerOutput = compiler.Compile(solcPath, filePath); AST ast = new AST(compilerOutput); ASTNode sourceUnits = ast.GetSourceUnits(); return(TextCompare(programText, sourceUnits.ToString())); }