BTDB.IL.ILDynamicMethodDebugImpl.CheckInPeVerify C# (CSharp) Method

CheckInPeVerify() public method

public CheckInPeVerify ( ) : void
return void
        void CheckInPeVerify()
        {
            const string peverifyPath =
                @"c:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\PEVerify.exe";
            if (!File.Exists(peverifyPath)) return;
            var fullyQualifiedName = _moduleBuilder.FullyQualifiedName;
            var nameInExeDirectory = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(fullyQualifiedName)), Path.GetFileName(fullyQualifiedName));
            File.Copy(fullyQualifiedName, nameInExeDirectory, true);
            var additionalDlls = new List<string>(Assembly.ReflectionOnlyLoadFrom(nameInExeDirectory).GetReferencedAssemblies().Select(a => a.Name + ".dll").Where(a => File.Exists(Path.Combine(DynamicILDirectoryPath.DynamicIL, a))));
            additionalDlls.ForEach(s => File.Copy(Path.Combine(DynamicILDirectoryPath.DynamicIL, s), s));
            var psi = new ProcessStartInfo(peverifyPath, nameInExeDirectory)
                {
                    CreateNoWindow = true,
                    RedirectStandardOutput = true,
                    UseShellExecute = false
                };
            using (var p = new Process())
            {
                p.StartInfo = psi;
                var output = new StringBuilder();
                p.OutputDataReceived += (sender, args) => output.AppendLine(args.Data);
                p.Start();
                p.BeginOutputReadLine();
                p.WaitForExit();
                if (p.ExitCode != 0)
                {
                    output.Append("PEVerify ended with " + p.ExitCode + " for " + fullyQualifiedName);
                    var text = output.ToString();
                    Trace.WriteLine(text);
                    //Debugger.Break();
                }
            }
            File.Delete(nameInExeDirectory);
            additionalDlls.ForEach(File.Delete);
        }