internal static PkgDefFile Parse(string pkgDefFile) { var file = new PkgDefFile(); string section = null; foreach (var line in File.ReadAllLines(pkgDefFile)) { if (line.StartsWith(';') || line.Trim().Length == 0) { continue; } else if (line.StartsWith('[')) { section = line.Trim('[', ']'); } else { if (section == null) { throw new InvalidOperationException("Couldn't find a section to start with"); } string key = line.Split('=').First().Trim('"'); string value = line.Split('=').Last().Trim('"'); file.SetValue(section, key, value); } } return(file); }
public static void Main(string leftFile, string rightFile) { Console.WriteLine("Comparing " + leftFile + " and " + rightFile); var left = PkgDefFile.Parse(leftFile); var right = PkgDefFile.Parse(rightFile); foreach (var section in left.GetSections()) { if (!right.HasSection(section)) { Console.WriteLine("Missing section: " + section); continue; } foreach (var key in left.GetKeys(section)) { if (!right.HasKey(section, key)) { Console.WriteLine("Missing key: " + section + ", " + key); continue; } string leftValue = left.GetValue(section, key); string rightValue = right.GetValue(section, key); if (!string.Equals(leftValue, rightValue, StringComparison.OrdinalIgnoreCase)) { // This change is acceptable if (leftValue.Equals(@"$System$\mscoree.dll") && rightValue.Equals(@"$WinDir$\SYSTEM32\MSCOREE.DLL")) { continue; } Console.WriteLine("Value differenct: " + section + ", " + key); Console.WriteLine(" |" + leftValue + "|"); Console.WriteLine(" |" + rightValue + "|"); continue; } } } }