DebugHelper.cs 983 B

12345678910111213141516171819202122232425262728293031
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. namespace Optimizer
  7. {
  8. // Collection of useful debugging methods and utilities
  9. internal sealed class DebugHelper
  10. {
  11. // For comparing and detecting missing keys between two translation JSON files
  12. internal static void FindDifferenceInTwoJsons()
  13. {
  14. JObject file1 = JObject.Parse(Properties.Resources.EN);
  15. JObject file2 = JObject.Parse(Properties.Resources.ID);
  16. var p1 = file1.Properties().ToList();
  17. var p2 = file2.Properties().ToList();
  18. var missingProps = p1.Where(expected => !p2.Where(actual => actual.Name == expected.Name).Any());
  19. StringBuilder sb = new StringBuilder();
  20. foreach (var x in missingProps)
  21. {
  22. sb.Append(x.Name + Environment.NewLine);
  23. }
  24. MessageBox.Show(sb.ToString());
  25. }
  26. }
  27. }