private void VerifyIL(AssemblyDefinition assembly) {
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ar_test.exe");
assembly.Write(path);
string peverify = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
@"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\PEVerify.exe"
);
var process = Process.Start(new ProcessStartInfo {
FileName = peverify,
Arguments = $"\"{path}\"",
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true
});
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
if(process.ExitCode != 0) {
throw new VerifyFailedException(process.ExitCode, output);
}
}