static void ParseErrors(PeVerifyResult result, string stdOut) { result.Errors = new List <string>(); int startIndex = 0; while (startIndex < stdOut.Length) { startIndex = stdOut.IndexOf("[IL]:", startIndex); if (startIndex == -1) { break; } int endIndex = stdOut.IndexOf("[IL]:", startIndex + 1); if (endIndex == -1) { // Look for the last line... endIndex = stdOut.IndexOf("\r\n", startIndex + 1); } result.Errors.Add(result.NormalizeErrorString(stdOut.Substring(startIndex, endIndex - startIndex))); startIndex = endIndex; } }
public static PeVerifyResult VerifyAssembly(string assemblyName) { PeVerifyResult result = new PeVerifyResult(); result.AssemblyName = assemblyName; string stdOut, stdErr; result.ExitCode = StartAndWaitForResult(PeVerifyPath, assemblyName + " /UNIQUE /IL /NOLOGO", out stdOut, out stdErr); ParseErrors(result, stdOut); return(result); }
public static void Assert(PeVerifyResult expectedResult, PeVerifyResult actualResult) { foreach (var e in expectedResult.Errors) { actualResult.Errors.Remove(e); } // TODO: Ideally this will be with peverify v4.0, and this won't be needed. if (actualResult.Errors.Count > expectedResult.Errors.Count) { Console.WriteLine("Expected:"); expectedResult.Errors.ForEach(Console.WriteLine); Console.WriteLine(); Console.WriteLine("Actual:"); actualResult.Errors.ForEach(Console.WriteLine); Console.WriteLine("PeVerify: {0}", expectedResult.AssemblyName); throw new Exception("PeVerify Failed with " + actualResult.Errors.Count + " different errors."); } }
static void ParseErrors(PeVerifyResult result, string stdOut) { result.Errors = new List<string>(); int startIndex = 0; while (startIndex < stdOut.Length) { startIndex = stdOut.IndexOf("[IL]:", startIndex); if (startIndex == -1) break; int endIndex = stdOut.IndexOf("[IL]:", startIndex + 1); if (endIndex == -1) { // Look for the last line... endIndex = stdOut.IndexOf("\r\n", startIndex + 1); } result.Errors.Add(result.NormalizeErrorString(stdOut.Substring(startIndex, endIndex - startIndex))); startIndex = endIndex; } }
public static PeVerifyResult VerifyAssembly(string assemblyName) { PeVerifyResult result = new PeVerifyResult(); result.AssemblyName = assemblyName; string stdOut, stdErr; result.ExitCode = StartAndWaitForResult(PeVerifyPath, assemblyName + " /UNIQUE /IL /NOLOGO", out stdOut, out stdErr); ParseErrors(result, stdOut); return result; }