protected void CheckCode(byte[] code) { var auditor = new CSharpContractAuditor(null, null); auditor.Audit(code, new RequiredAcs { AcsList = new List <string>() }); }
private static void Run(Options o) { string saveAsPath; if (!File.Exists(o.ContractDllPath)) { Console.WriteLine($"error: Contract DLL cannot be found in specified path {o.ContractDllPath}"); return; } if (o.Overwrite) { saveAsPath = o.ContractDllPath; Console.WriteLine($"[CONTRACT-PATCHER] Overwriting {saveAsPath}"); } else { saveAsPath = o.ContractDllPath + ".patched"; Console.WriteLine($"[CONTRACT-PATCHER] Saving as {saveAsPath}"); } var patchedCode = ContractPatcher.Patch(File.ReadAllBytes(o.ContractDllPath)); if (!o.SkipAudit) { try { var auditor = new CSharpContractAuditor(null, null); auditor.Audit(patchedCode, null); } catch (CSharpInvalidCodeException ex) { foreach (var finding in ex.Findings) { // Print error in parsable format so that it can be shown in IDE Console.WriteLine($"error: {finding.ToString()}"); } } } File.WriteAllBytes(saveAsPath, patchedCode); }