-
Notifications
You must be signed in to change notification settings - Fork 0
/
Verifier.cs
44 lines (39 loc) · 1.34 KB
/
Verifier.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Build.Utilities;
using NUnit.Framework;
public static class Verifier
{
public static void Verify(string beforeAssemblyPath, string afterAssemblyPath)
{
var before = Validate(beforeAssemblyPath);
var after = Validate(afterAssemblyPath);
var message = $"Failed processing {Path.GetFileName(afterAssemblyPath)}\r\n{after}";
Assert.AreEqual(TrimLineNumbers(before), TrimLineNumbers(after), message);
}
static string Validate(string assemblyPath2)
{
var exePath = GetPathToPeVerify();
if (!File.Exists(exePath))
{
return string.Empty;
}
var process = Process.Start(new ProcessStartInfo(exePath, "\"" + assemblyPath2 + "\"")
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
});
process.WaitForExit(10000);
return process.StandardOutput.ReadToEnd().Trim().Replace(assemblyPath2, "");
}
static string GetPathToPeVerify()
{
return ToolLocationHelper.GetPathToDotNetFrameworkFile("peverify.exe",TargetDotNetFrameworkVersion.VersionLatest);
}
static string TrimLineNumbers(string foo)
{
return Regex.Replace(foo, @"0x.*]", "");
}
}