public void ClassTest()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);

      // [ModuleOld]NsOld.ClassOld -> [ModuleNew]NsNew.ClassNew
      RenamedClass renamedClass = mapping.Classes[0];
      Assert.AreEqual(11, renamedClass.Items.Count);
      Assert.AreEqual("ModuleOld", renamedClass.ModuleOld);
      Assert.AreEqual("ModuleNew", renamedClass.ModuleNew);
      Assert.AreEqual("NsOld.ClassOld", renamedClass.NameOld);
      Assert.AreEqual("NsNew.ClassNew", renamedClass.NameNew);
      Assert.AreEqual("NsOld.ClassOld", renamedClass.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew", renamedClass.NameNewPlain);
      Assert.AreEqual("NsOld.ClassOld", renamedClass.NameOldSimple);
      Assert.AreEqual("NsNew.ClassNew", renamedClass.NameNewSimple);
      Assert.AreEqual("[ModuleOld]NsOld.ClassOld", renamedClass.NameOldFull);
      Assert.AreEqual("[ModuleNew]NsNew.ClassNew", renamedClass.NameNewFull);
      Assert.AreEqual("NsOld.ClassOld → NsNew.ClassNew", renamedClass.TransformName);
      Assert.AreEqual("NsOld.ClassOld → NsNew.ClassNew", renamedClass.TransformSimple);
      Assert.AreEqual("NsOld → NsNew", renamedClass.TransformNamespace);
      Assert.AreEqual("[ModuleOld]NsOld.ClassOld → [ModuleNew]NsNew.ClassNew", renamedClass.TransformNameFull);
      Assert.AreEqual("NsOld.ClassOld → NsNew.ClassNew", renamedClass.ToString());
    }
    public void FieldTest()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);
      RenamedClass renamedClass = mapping.Classes[0];

      // [ModuleOld]NsOld.ClassOld NsOld.ClassOld::ClassFieldOld -> ClassFieldNew
      RenamedItem renamedItem = (RenamedItem)renamedClass.Items[0];
      Assert.AreEqual(EntityType.Field, renamedItem.EntityType);
      Assert.IsNotNull(renamedItem.ResultType);
      Assert.AreEqual(renamedClass.Name.NameOld, renamedItem.ResultType.NameOld);
      Assert.AreEqual(renamedClass.Name.NameNew, renamedItem.ResultType.NameNew);
      Assert.IsNull(renamedItem.MethodParams);
      Assert.IsNotNull(renamedItem.Owner);
      Assert.AreEqual(renamedClass, renamedItem.Owner);
      Assert.AreEqual("ModuleOld", renamedItem.ModuleOld);
      Assert.AreEqual("ModuleNew", renamedItem.ModuleNew);
      Assert.AreEqual("ClassOld ClassFieldOld", renamedItem.NameOld);
      Assert.AreEqual("ClassNew ClassFieldNew", renamedItem.NameNew);
      Assert.AreEqual("NsOld.ClassOld.ClassFieldOld", renamedItem.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew.ClassFieldNew", renamedItem.NameNewPlain);
      Assert.AreEqual("NsOld.ClassOld NsOld.ClassOld.ClassFieldOld", renamedItem.NameOldFull);
      Assert.AreEqual("NsNew.ClassNew NsNew.ClassNew.ClassFieldNew", renamedItem.NameNewFull);
      Assert.AreEqual("ClassOld NsOld.ClassOld.ClassFieldOld", renamedItem.NameOldSimple);
      Assert.AreEqual("ClassNew NsNew.ClassNew.ClassFieldNew", renamedItem.NameNewSimple);
      Assert.AreEqual("ClassOld ClassFieldOld → ClassNew ClassFieldNew", renamedItem.TransformName);
      Assert.AreEqual("NsOld.ClassOld NsOld.ClassOld.ClassFieldOld → NsNew.ClassNew NsNew.ClassNew.ClassFieldNew", renamedItem.TransformNameFull);
      Assert.AreEqual("ClassOld NsOld.ClassOld.ClassFieldOld → ClassNew NsNew.ClassNew.ClassFieldNew", renamedItem.TransformSimple);
      Assert.AreEqual("ClassOld NsOld.ClassOld.ClassFieldOld → ClassNew NsNew.ClassNew.ClassFieldNew", renamedItem.ToString());
    }
    public SettingsForm(Mapping mapping)
    {
      this.mapping = mapping;
      InitializeComponent();

      lbVS.Items.Add(VSOpener.VisualStudioVersion.Notepad);
      if (VSOpener.VisualStudioVersions != null)
        foreach (VSOpener.VisualStudioVersion version in VSOpener.VisualStudioVersions)
          lbVS.Items.Add(version);

      cbShowUnicode.Checked = Configs.Instance.ShowUnicode;
      cbSimplifySystemNames.Checked = Configs.Instance.SimplifySystemNames;
      cbSimplifyNullable.Checked = Configs.Instance.SimplifyNullable;
      cbGroupByNamespaces.Checked = Configs.Instance.GroupNamespaces;
      cbGroupByModules.Checked = Configs.Instance.GroupModules;
      cbUseColumns.Checked = Configs.Instance.UseColumns;

      string vs = Configs.Instance.GetRecentProperty(mapping.Filename, "editor");
      if (vs == null)
        lbVS.SelectedItem = Configs.Instance.VisualStudioVersion;
      else
      {
        lbVS.SelectedItem = Enum.Parse(typeof(VSOpener.VisualStudioVersion), vs);
        cbApplyVsToProject.Checked = true;
      }
    }
    public void GenericFieldTest()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);
      RenamedClass renamedClass = mapping.Classes[0];

      // [ModuleOld]System.Collections.Generic.Dictionary`2<System.String,System.String> NsOld.ClassOld::GenericFieldOld -> GenericFieldNew
      RenamedItem renamedItem = (RenamedItem)renamedClass.Items[1];
      Assert.AreEqual(EntityType.Field, renamedItem.EntityType);
      Assert.IsNotNull(renamedItem.ResultType);
      Assert.AreEqual("System.Collections.Generic.Dictionary<System.String, System.String>", renamedItem.ResultType.NameOld.ToString());
      Assert.AreEqual("System.Collections.Generic.Dictionary<System.String, System.String>", renamedItem.ResultType.NameNew.ToString());
      Assert.IsNull(renamedItem.MethodParams);
      Assert.IsNotNull(renamedItem.Owner);
      Assert.AreEqual(renamedClass, renamedItem.Owner);
      Assert.AreEqual("ModuleOld", renamedItem.ModuleOld);
      Assert.AreEqual("ModuleNew", renamedItem.ModuleNew);
      Assert.AreEqual("Dictionary<String, String> GenericFieldOld", renamedItem.NameOld);
      Assert.AreEqual("Dictionary<String, String> GenericFieldNew", renamedItem.NameNew);
      Assert.AreEqual("NsOld.ClassOld.GenericFieldOld", renamedItem.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew.GenericFieldNew", renamedItem.NameNewPlain);
      Assert.AreEqual("System.Collections.Generic.Dictionary<System.String, System.String> NsOld.ClassOld.GenericFieldOld", renamedItem.NameOldFull);
      Assert.AreEqual("System.Collections.Generic.Dictionary<System.String, System.String> NsNew.ClassNew.GenericFieldNew", renamedItem.NameNewFull);
      Assert.AreEqual("Dictionary<String, String> NsOld.ClassOld.GenericFieldOld", renamedItem.NameOldSimple);
      Assert.AreEqual("Dictionary<String, String> NsNew.ClassNew.GenericFieldNew", renamedItem.NameNewSimple);
      Assert.AreEqual("Dictionary<String, String> GenericFieldOld → Dictionary<String, String> GenericFieldNew", renamedItem.TransformName);
      Assert.AreEqual("System.Collections.Generic.Dictionary<System.String, System.String> NsOld.ClassOld.GenericFieldOld → System.Collections.Generic.Dictionary<System.String, System.String> NsNew.ClassNew.GenericFieldNew", renamedItem.TransformNameFull);
      Assert.AreEqual("Dictionary<String, String> NsOld.ClassOld.GenericFieldOld → Dictionary<String, String> NsNew.ClassNew.GenericFieldNew", renamedItem.TransformSimple);
      Assert.AreEqual("Dictionary<String, String> NsOld.ClassOld.GenericFieldOld → Dictionary<String, String> NsNew.ClassNew.GenericFieldNew", renamedItem.ToString());
    }
    public void Test1()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\Mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\test1.txt"));

      Assert.AreEqual(5, results.Count);

      ResultTestHelperOk(
          results,
          0,
          "AntiFreeze.Core",
          "void GetReader(IDbCommand, String)",
          "void AntiFreeze.Core.DataBase.GetReader(IDbCommand, String)",
          "void AntiFreeze.Core.DataBase.GetReader(System.Data.IDbCommand, System.String)"
        );

      ResultTestHelperOk(
          results,
          1,
          "AntiFreeze.Core",
          "void GetReader(String)",
          "void AntiFreeze.Core.DataBase.GetReader(String)",
          "void AntiFreeze.Core.DataBase.GetReader(System.String)"
        );

      ResultTestHelperOk(
          results,
          2,
          "AntiFreeze.NET",
          "void SetupNativeAPI()",
          "void AntiFreeze.NET.NativeAPI.SetupNativeAPI()",
          "void AntiFreeze.NET.NativeAPI.SetupNativeAPI()"
        );

      ResultTestHelperOk(
          results,
          3,
          "AntiFreeze.NET",
          "void Startup()",
          "void AntiFreeze.NET.MainForm.Startup()",
          "void AntiFreeze.NET.MainForm.Startup()"
        );

      ResultTestHelperOk(
          results,
          4,
          "AntiFreeze.NET",
          "void MainForm_Load(Object, EventArgs)",
          "void AntiFreeze.NET.MainForm.MainForm_Load(Object, EventArgs)",
          "void AntiFreeze.NET.MainForm.MainForm_Load(System.Object, System.EventArgs)"
        );
    }
 public StatisticsForm(Mapping mapping)
 {
   InitializeComponent();
   lblClassesValue.Text = mapping.TotalClassesCount.ToString();
   lblMethodsValue.Text = mapping.TotalMethodsCount.ToString();
   lblSubclassesValue.Text = mapping.TotalSubclassesCount.ToString();
   lblModulesValue.Text = mapping.ModulesCount.ToString();
   lblNsValue.Text = mapping.NamespacesCount.ToString();
   lblNs2Value.Text = mapping.ObfuscatedNamespacesCount.ToString();
   lblSkippedValue.Text = mapping.SkippedEntities.ToString();
   llblFilename.Text = mapping.Filename;
 }
    private static void Process(string filename)
    {
      if (doAttach && !AttachConsole(ATTACH_PARENT_PROCESS))
        return;

      Mapping mapping = new Mapping(filename);
      StringBuilder sb = new StringBuilder();
      string s;
      while (!string.IsNullOrEmpty(s = Console.ReadLine()))
        sb.AppendLine(s);

      Console.WriteLine(mapping.ProcessCrashlogText(sb.ToString()));
    }
 private void Start()
 {
   try
   {
     mapping = new Mapping(filename);
     if (loadingThreadCompleted != null)
       loadingThreadCompleted(mapping, filename);
   }
   catch (Exception e)
   {
     if (loadingThreadCompleted != null)
       loadingThreadCompleted(e, filename);
   }
 }
    public StacktraceSource(Mapping mapping)
    {
      this.mapping = mapping;
      InitializeComponent();

      tbFilename.SetCueText("Select file to read stacktrace");
      tbURL.SetCueText("Type URL to get stacktrace");

      controlHighlight.OwnerForm = this;

      foreach (string s in Configs.Instance.GetRecentAdditional(mapping.Filename, RECENT_URLS))
        tbURL.AutoCompleteCustomSource.Add(s);

      foreach (string s in Configs.Instance.GetRecentAdditional(mapping.Filename, RECENT_FILES))
        tbFilename.AutoCompleteCustomSource.Add(s);
    }
    public void TwoParamMethodTest()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);
      RenamedClass renamedClass = mapping.Classes[0];

      // [ModuleOld]System.String NsOld.ClassOld::MethodWithParam2Old([ModuleOld]NsOld.ClassOld,System.String) -> MethodWithParam2New
      RenamedItem renamedItem = (RenamedItem)renamedClass.Items[6];
      Assert.AreEqual(EntityType.Method, renamedItem.EntityType);
      Assert.IsNotNull(renamedItem.ResultType);
      Assert.AreEqual("System.String", renamedItem.ResultType.NameOld.ToString());
      Assert.AreEqual("System.String", renamedItem.ResultType.NameNew.ToString());
      Assert.IsNotNull(renamedItem.MethodParams);
      Assert.AreEqual(2, renamedItem.MethodParams.Count);
      Assert.AreEqual("NsOld.ClassOld", renamedItem.MethodParams[0].NameOld.ToString());
      Assert.AreEqual("NsNew.ClassNew", renamedItem.MethodParams[0].NameNew.ToString());
      Assert.AreEqual("System.String", renamedItem.MethodParams[1].NameOld.ToString());
      Assert.AreEqual("System.String", renamedItem.MethodParams[1].NameNew.ToString());
      Assert.IsNotNull(renamedItem.Owner);
      Assert.AreEqual(renamedClass, renamedItem.Owner);
      Assert.AreEqual("ModuleOld", renamedItem.ModuleOld);
      Assert.AreEqual("ModuleNew", renamedItem.ModuleNew);
      Assert.AreEqual("String MethodWithParam2Old(ClassOld, String)", renamedItem.NameOld);
      Assert.AreEqual("String MethodWithParam2New(ClassNew, String)", renamedItem.NameNew);
      Assert.AreEqual("NsOld.ClassOld.MethodWithParam2Old", renamedItem.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew.MethodWithParam2New", renamedItem.NameNewPlain);
      Assert.AreEqual("System.String NsOld.ClassOld.MethodWithParam2Old(NsOld.ClassOld, System.String)", renamedItem.NameOldFull);
      Assert.AreEqual("System.String NsNew.ClassNew.MethodWithParam2New(NsNew.ClassNew, System.String)", renamedItem.NameNewFull);
      Assert.AreEqual("String NsOld.ClassOld.MethodWithParam2Old(ClassOld, String)", renamedItem.NameOldSimple);
      Assert.AreEqual("String NsNew.ClassNew.MethodWithParam2New(ClassNew, String)", renamedItem.NameNewSimple);
      Assert.AreEqual("String MethodWithParam2Old(ClassOld, String) → String MethodWithParam2New(ClassNew, String)", renamedItem.TransformName);
      Assert.AreEqual("System.String NsOld.ClassOld.MethodWithParam2Old(NsOld.ClassOld, System.String) → System.String NsNew.ClassNew.MethodWithParam2New(NsNew.ClassNew, System.String)", renamedItem.TransformNameFull);
      Assert.AreEqual("String NsOld.ClassOld.MethodWithParam2Old(ClassOld, String) → String NsNew.ClassNew.MethodWithParam2New(ClassNew, String)", renamedItem.TransformSimple);
      Assert.AreEqual("String NsOld.ClassOld.MethodWithParam2Old(ClassOld, String) → String NsNew.ClassNew.MethodWithParam2New(ClassNew, String)", renamedItem.ToString());
    }
    public void UnicodeTest1Simplify()
    {
      Configs.Instance.SimplifySystemNames = true;
      Mapping mapping = new Mapping(@"Data\unicode_mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\unicode_test1.txt"));

      Assert.AreEqual(5, results.Count);

      ResultTestHelperSubstitution(
          results,
          0,
          "ctor(string)",
          "ObfuscarMappingParser.Entity.ctor(string)",
          "ObfuscarMappingParser.Entity.ctor(string)"
        );
      ResultTestHelperOk(
          results,
          1,
          "ObfuscarMappingParser",
          "void Search(string, bool)",
          "void ObfuscarMappingParser.Mapping.Search(string, bool)",
          "void ObfuscarMappingParser.Mapping.Search(string, bool)"
        );
      ResultTestHelperOk(
          results,
          2,
          "ObfuscarMappingParser",
          "void ProcessCrashlog(string)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlog(string)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlog(string)"
        );
      ResultTestHelperOk(
          results,
          3,
          "ObfuscarMappingParser",
          "void ProcessCrashlogText(string)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlogText(string)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlogText(string)"
        );
      ResultTestHelperOk(
          results,
          4,
          "ObfuscarMappingParser",
          "void btnProcess_Click(object, EventArgs)",
          "void ObfuscarMappingParser.CrashLog.btnProcess_Click(object, EventArgs)",
          "void ObfuscarMappingParser.CrashLog.btnProcess_Click(object, System.EventArgs)"
        );
    }
    public void KoreanTest1()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\korean_mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\korean_test1.txt"));

      Assert.AreEqual(5, results.Count);

      ResultTestHelperSubstitution(
          results,
          0,
          "ctor(String)",
          "ObfuscarMappingParser.Entity.ctor(String)",
          "ObfuscarMappingParser.Entity.ctor(String)"
        );
      ResultTestHelperOk(
          results,
          1,
          "ObfuscarMappingParser",
          "void Search(String, Boolean)",
          "void ObfuscarMappingParser.Mapping.Search(String, Boolean)",
          "void ObfuscarMappingParser.Mapping.Search(System.String, System.Boolean)"
        );
      ResultTestHelperOk(
          results,
          2,
          "ObfuscarMappingParser",
          "void ProcessCrashlog(String)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlog(String)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlog(System.String)"
        );
      ResultTestHelperOk(
          results,
          3,
          "ObfuscarMappingParser",
          "void ProcessCrashlogText(String)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlogText(String)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlogText(System.String)"
        );
      ResultTestHelperOk(
          results,
          4,
          "ObfuscarMappingParser",
          "void btnProcess_Click(Object, EventArgs)",
          "void ObfuscarMappingParser.CrashLog.btnProcess_Click(Object, EventArgs)",
          "void ObfuscarMappingParser.CrashLog.btnProcess_Click(System.Object, System.EventArgs)"
        );
    }
    public void Test1Broken()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\Mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\test1_broken.txt"), false);

      Assert.AreEqual(5, results.Count);

      ResultTestHelperMultiple(
          results,
          0,
          "void get_IsNewDataBase()",
          "void AntiFreeze.Core.DataBase.get_IsNewDataBase()",
          "void AntiFreeze.Core.DataBase.get_IsNewDataBase()"
        );

      ResultTestHelperMultiple(
          results,
          1,
          "void get_Command()",
          "void AntiFreeze.Core.DataBase.get_Command()",
          "void AntiFreeze.Core.DataBase.get_Command()"
        );

      ResultTestHelperMultiple(
          results,
          2,
          "void SetupNativeAPI()",
          "void AntiFreeze.NET.NativeAPI.SetupNativeAPI()",
          "void AntiFreeze.NET.NativeAPI.SetupNativeAPI()"
        );

      ResultTestHelperMultiple(
          results,
          3,
          "void ThreadActionItem_Click(Object, EventArgs)",
          "void AntiFreeze.NET.MainForm.ThreadActionItem_Click(Object, EventArgs)",
          "void AntiFreeze.NET.MainForm.ThreadActionItem_Click(System.Object, System.EventArgs)"
        );

      ResultTestHelperOk(
          results,
          4,
          "AntiFreeze.NET",
          "void MainForm_Load(Object, EventArgs)",
          "void AntiFreeze.NET.MainForm.MainForm_Load(Object, EventArgs)",
          "void AntiFreeze.NET.MainForm.MainForm_Load(System.Object, System.EventArgs)"
        );
    }
    public void Test6Simpify()
    {
      Configs.Instance.SimplifySystemNames = true;
      Mapping mapping = new Mapping(@"Data\Mapping_Parser.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\test6.txt"));

      Assert.AreEqual(6, results.Count);

      ResultTestHelperSubstitution(
          results,
          0,
          "ctor(MainForm, string, string)",
          "ObfuscarMappingParser.StacktraceAnalyerForm.ctor(MainForm, string, string)",
          "ObfuscarMappingParser.StacktraceAnalyerForm.ctor(ObfuscarMappingParser.MainForm, string, string)"
        );

      ResultTestHelperOk(
          results,
          1,
          "ObfuscarMappingParser",
          "void miStacktrace_Click(object, EventArgs)",
          "void ObfuscarMappingParser.MainForm.miStacktrace_Click(object, EventArgs)",
          "void ObfuscarMappingParser.MainForm.miStacktrace_Click(object, System.EventArgs)"
        );

      ResultTestHelper(
          results,
          2,
          "void RaiseEvent(object, EventArgs)",
          "void System.Windows.Forms.ToolStripItem.RaiseEvent(object, EventArgs)",
          "void System.Windows.Forms.ToolStripItem.RaiseEvent(object, EventArgs)"
        );

      ResultTestHelper(
          results,
          3,
          "void OnClick(EventArgs)",
          "void System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs)",
          "void System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs)"
        );

      ResultTestHelper(
          results,
          4,
          "void HandleClick(EventArgs)",
          "void System.Windows.Forms.ToolStripItem.HandleClick(EventArgs)",
          "void System.Windows.Forms.ToolStripItem.HandleClick(EventArgs)"
        );

      ResultTestHelper(
          results,
          5,
          "void HandleMouseUp(MouseEventArgs)",
          "void System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs)",
          "void System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs)"
        );
    }
 public MappingReloaderThread(Mapping mapping)
 {
   this.mapping = mapping;
 }
    public void Test5Nl()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\Mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\test5_nl.txt"));
      Assert.AreEqual(3, results.Count);

      ResultTestHelperOk(
          results,
          0,
          "AntiFreeze.Basic",
          "void DrawGraph(Rectangle, Single, Single, Graphics)",
          "void AntiFreeze.Basic.PingResultPanel.DrawGraph(Rectangle, Single, Single, Graphics)",
          "void AntiFreeze.Basic.PingResultPanel.DrawGraph(System.Drawing.Rectangle, System.Single, System.Single, System.Drawing.Graphics)"
        );

      ResultTestHelperOk(
          results,
          1,
          "AntiFreeze.Core",
          "void Draw(Graphics)",
          "void AntiFreeze.Core.GraphResultPanel.Draw(Graphics)",
          "void AntiFreeze.Core.GraphResultPanel.Draw(System.Drawing.Graphics)"
        );

      ResultTestHelperSubstitution(
          results,
          2,
          "void OnPaint(PaintEventArgs)",
          "void AntiFreeze.NET.WorkPanel.OnPaint(PaintEventArgs)",
          "void AntiFreeze.NET.WorkPanel.OnPaint(PaintEventArgs)"
        );
    }
    public void Test2()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\Mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\test2.txt"));

      Assert.AreEqual(1, results.Count);

      ResultTestHelperOk(
          results,
          0,
          "AntiFreeze.NET",
          "void DwmSetWindowAttribute(IntPtr, Int32, Int32&, Int32)",
          "void BrokenEvent.Shared.AeroPeekModifier.DwmSetWindowAttribute(IntPtr, Int32, Int32&, Int32)",
          "void BrokenEvent.Shared.AeroPeekModifier.DwmSetWindowAttribute(System.IntPtr, System.Int32, System.Int32&, System.Int32)"
        );
    }
    public void Test3()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\Mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\test3.txt"));

      Assert.AreEqual(7, results.Count);

      ResultTestHelper(
          results,
          0,
          "void StartWithShellExecuteEx(ProcessStartInfo)",
          "void System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo)",
          "void System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo)"
        );

      ResultTestHelper(
          results,
          1,
          "void Start()",
          "void System.Diagnostics.Process.Start()",
          "void System.Diagnostics.Process.Start()"
        );

      ResultTestHelper(
          results,
          2,
          "void Start(ProcessStartInfo)",
          "void System.Diagnostics.Process.Start(ProcessStartInfo)",
          "void System.Diagnostics.Process.Start(ProcessStartInfo)"
        );

      ResultTestHelper(
          results,
          3,
          "void Start(String)",
          "void System.Diagnostics.Process.Start(String)",
          "void System.Diagnostics.Process.Start(String)"
        );

      ResultTestHelperOk(
          results,
          4,
          "AntiFreeze.NET",
          "void llblSupportEmail_LinkClicked(Object, LinkLabelLinkClickedEventArgs)",
          "void AntiFreeze.NET.AboutForm.llblSupportEmail_LinkClicked(Object, LinkLabelLinkClickedEventArgs)",
          "void AntiFreeze.NET.AboutForm.llblSupportEmail_LinkClicked(System.Object, System.Windows.Forms.LinkLabelLinkClickedEventArgs)"
        );

      ResultTestHelper(
          results,
          5,
          "void OnLinkClicked(LinkLabelLinkClickedEventArgs)",
          "void System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs)",
          "void System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs)"
        );

      ResultTestHelper(
          results,
          6,
          "void OnMouseUp(MouseEventArgs)",
          "void System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs)",
          "void System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs)"
        );
    }
    public void SomethingWickedTest()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);
      RenamedClass renamedClass = mapping.Classes[0];

      // [ModuleOld]NsOld.ClassOld::<Initialize>m__D[0]() -> I
      RenamedItem renamedItem = (RenamedItem)renamedClass.Items[7];
      Assert.AreEqual(EntityType.Method, renamedItem.EntityType);
      Assert.IsNull(renamedItem.ResultType);
      Assert.IsNotNull(renamedItem.MethodParams);
      Assert.AreEqual(0, renamedItem.MethodParams.Count);
      Assert.IsNotNull(renamedItem.Owner);
      Assert.AreEqual(renamedClass, renamedItem.Owner);
      Assert.AreEqual("ModuleOld", renamedItem.ModuleOld);
      Assert.AreEqual("ModuleNew", renamedItem.ModuleNew);
      Assert.AreEqual("void <Initialize>m__D()", renamedItem.NameOld);
      Assert.AreEqual("void I()", renamedItem.NameNew);
      Assert.AreEqual("NsOld.ClassOld.<Initialize>m__D", renamedItem.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew.I", renamedItem.NameNewPlain);
      Assert.AreEqual("void NsOld.ClassOld.<Initialize>m__D()", renamedItem.NameOldFull);
      Assert.AreEqual("void NsNew.ClassNew.I()", renamedItem.NameNewFull);
      Assert.AreEqual("void NsOld.ClassOld.<Initialize>m__D()", renamedItem.NameOldSimple);
      Assert.AreEqual("void NsNew.ClassNew.I()", renamedItem.NameNewSimple);
      Assert.AreEqual("void <Initialize>m__D() → void I()", renamedItem.TransformName);
      Assert.AreEqual("void NsOld.ClassOld.<Initialize>m__D() → void NsNew.ClassNew.I()", renamedItem.TransformNameFull);
      Assert.AreEqual("void NsOld.ClassOld.<Initialize>m__D() → void NsNew.ClassNew.I()", renamedItem.TransformSimple);
      Assert.AreEqual("void NsOld.ClassOld.<Initialize>m__D() → void NsNew.ClassNew.I()", renamedItem.ToString());     
    }
 public CrashLogForm(Mapping mapping)
 {
   this.mapping = mapping;
   InitializeComponent();
 }
    public void PropertySimplifyTest()
    {
      Configs.Instance.SimplifySystemNames = true;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);
      RenamedClass renamedClass = mapping.Classes[0];

      // [ModuleOld]System.String NsOld.ClassOld::StringFieldOld -> StringFieldNew
      RenamedItem renamedItem = (RenamedItem)renamedClass.Items[2];
      Assert.AreEqual(EntityType.Property, renamedItem.EntityType);
      Assert.IsNotNull(renamedItem.ResultType);
      Assert.AreEqual("System.String", renamedItem.ResultType.NameOld.ToString());
      Assert.AreEqual("System.String", renamedItem.ResultType.NameNew.ToString());
      Assert.IsNull(renamedItem.MethodParams);
      Assert.IsNotNull(renamedItem.Owner);
      Assert.AreEqual(renamedClass, renamedItem.Owner);
      Assert.AreEqual("ModuleOld", renamedItem.ModuleOld);
      Assert.AreEqual("ModuleNew", renamedItem.ModuleNew);
      Assert.AreEqual("string StringFieldOld", renamedItem.NameOld);
      Assert.AreEqual("string StringFieldNew", renamedItem.NameNew);
      Assert.AreEqual("NsOld.ClassOld.StringFieldOld", renamedItem.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew.StringFieldNew", renamedItem.NameNewPlain);
      Assert.AreEqual("string NsOld.ClassOld.StringFieldOld", renamedItem.NameOldFull);
      Assert.AreEqual("string NsNew.ClassNew.StringFieldNew", renamedItem.NameNewFull);
      Assert.AreEqual("string NsOld.ClassOld.StringFieldOld", renamedItem.NameOldSimple);
      Assert.AreEqual("string NsNew.ClassNew.StringFieldNew", renamedItem.NameNewSimple);
      Assert.AreEqual("string StringFieldOld → string StringFieldNew", renamedItem.TransformName);
      Assert.AreEqual("string NsOld.ClassOld.StringFieldOld → string NsNew.ClassNew.StringFieldNew", renamedItem.TransformNameFull);
      Assert.AreEqual("string NsOld.ClassOld.StringFieldOld → string NsNew.ClassNew.StringFieldNew", renamedItem.TransformSimple);
      Assert.AreEqual("string NsOld.ClassOld.StringFieldOld → string NsNew.ClassNew.StringFieldNew", renamedItem.ToString());
    }
    public void SubclassMethodWithResultTest()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);
      RenamedClass renamedClass = mapping.Classes[0];
      RenamedClass subclass = (RenamedClass)renamedClass.Items[8];

      // [ModuleOld]NsOld.ClassOld/SubclassOld NsOld.ClassOld/SubclassOld::SubclassResultMethodOld() -> SubclassResultMethodNew
      RenamedItem renamedItem = (RenamedItem)subclass.Items[2];
      Assert.AreEqual(EntityType.Method, renamedItem.EntityType);
      Assert.IsNotNull(renamedItem.ResultType);
      Assert.AreEqual("NsOld.ClassOld.SubclassOld", renamedItem.ResultType.NameOld.ToString());
      Assert.AreEqual("NsNew.ClassNew.SubclassNew", renamedItem.ResultType.NameNew.ToString());
      Assert.IsNotNull(renamedItem.MethodParams);
      Assert.AreEqual(0, renamedItem.MethodParams.Count);
      Assert.IsNotNull(renamedItem.Owner);
      Assert.AreEqual(subclass, renamedItem.Owner);
      Assert.AreEqual("ModuleOld", renamedItem.ModuleOld);
      Assert.AreEqual("ModuleNew", renamedItem.ModuleNew);
      Assert.AreEqual("SubclassOld SubclassResultMethodOld()", renamedItem.NameOld);
      Assert.AreEqual("SubclassNew SubclassResultMethodNew()", renamedItem.NameNew);
      Assert.AreEqual("NsOld.ClassOld.SubclassOld NsOld.ClassOld.SubclassOld.SubclassResultMethodOld()", renamedItem.NameOldFull);
      Assert.AreEqual("NsNew.ClassNew.SubclassNew NsNew.ClassNew.SubclassNew.SubclassResultMethodNew()", renamedItem.NameNewFull);
      Assert.AreEqual("NsOld.ClassOld.SubclassOld.SubclassResultMethodOld", renamedItem.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew.SubclassNew.SubclassResultMethodNew", renamedItem.NameNewPlain);
      Assert.AreEqual("SubclassOld NsOld.ClassOld.SubclassOld.SubclassResultMethodOld()", renamedItem.NameOldSimple);
      Assert.AreEqual("SubclassNew NsNew.ClassNew.SubclassNew.SubclassResultMethodNew()", renamedItem.NameNewSimple);
      Assert.AreEqual("SubclassOld SubclassResultMethodOld() → SubclassNew SubclassResultMethodNew()", renamedItem.TransformName);
      Assert.AreEqual("NsOld.ClassOld.SubclassOld NsOld.ClassOld.SubclassOld.SubclassResultMethodOld() → NsNew.ClassNew.SubclassNew NsNew.ClassNew.SubclassNew.SubclassResultMethodNew()", renamedItem.TransformNameFull);
      Assert.AreEqual("SubclassOld NsOld.ClassOld.SubclassOld.SubclassResultMethodOld() → SubclassNew NsNew.ClassNew.SubclassNew.SubclassResultMethodNew()", renamedItem.TransformSimple);
      Assert.AreEqual("SubclassOld NsOld.ClassOld.SubclassOld.SubclassResultMethodOld() → SubclassNew NsNew.ClassNew.SubclassNew.SubclassResultMethodNew()", renamedItem.ToString());
    }
    public void SkippedByNewNameSubclassTest()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
      Assert.AreEqual(1, mapping.Classes.Count);
      RenamedClass renamedClass = mapping.Classes[0];

      // skipped [ModuleOld]NsOld.ClassOld/SkippedSubclass2
      RenamedClass subclass = (RenamedClass)renamedClass.Items[10];
      Assert.AreEqual(0, subclass.Items.Count);
      Assert.IsNotNull(subclass.SkipReason);
      Assert.AreEqual("ModuleOld", subclass.ModuleOld);
      Assert.AreEqual("ModuleNew", subclass.ModuleNew);
      Assert.AreEqual("NsOld.ClassOld.SkippedSubclass2", subclass.NameOld);
      Assert.AreEqual("NsNew.ClassNew.SkippedSubclass2", subclass.NameNew);
      Assert.AreEqual("NsOld.ClassOld.SkippedSubclass2", subclass.NameOldSimple);
      Assert.AreEqual("NsNew.ClassNew.SkippedSubclass2", subclass.NameNewSimple);
      Assert.AreEqual("[ModuleOld]NsOld.ClassOld.SkippedSubclass2", subclass.NameOldFull);
      Assert.AreEqual("[ModuleNew]NsNew.ClassNew.SkippedSubclass2", subclass.NameNewFull);
      Assert.AreEqual("NsOld.ClassOld.SkippedSubclass2", subclass.NameOldPlain);
      Assert.AreEqual("NsNew.ClassNew.SkippedSubclass2", subclass.NameNewPlain);
      Assert.AreEqual("NsOld.ClassOld.SkippedSubclass2 → NsNew.ClassNew.SkippedSubclass2", subclass.TransformName);
      Assert.AreEqual("NsOld.ClassOld.SkippedSubclass2 → NsNew.ClassNew.SkippedSubclass2", subclass.TransformSimple);
      Assert.AreEqual("NsOld → NsNew", subclass.TransformNamespace);
      Assert.AreEqual("[ModuleOld]NsOld.ClassOld.SkippedSubclass2 → [ModuleNew]NsNew.ClassNew.SkippedSubclass2", subclass.TransformNameFull);
      Assert.AreEqual("NsOld.ClassOld.SkippedSubclass2 → NsNew.ClassNew.SkippedSubclass2", subclass.ToString());
    }
    public void KoreanTest2()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\korean_mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\korean_test2.txt"));

      Assert.AreEqual(4, results.Count);

      ResultTestHelperSubstitution(
          results,
          0,
          "ctor(String)",
          "ObfuscarMappingParser.Entity.ctor(String)",
          "ObfuscarMappingParser.Entity.ctor(String)"
        );
      ResultTestHelperOk(
          results,
          1,
          "ObfuscarMappingParser",
          "void Search(String, Boolean)",
          "void ObfuscarMappingParser.Mapping.Search(String, Boolean)",
          "void ObfuscarMappingParser.Mapping.Search(System.String, System.Boolean)"
        );
      ResultTestHelperOk(
          results,
          2,
          "ObfuscarMappingParser",
          "void ProcessCrashlog(String)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlog(String)",
          "void ObfuscarMappingParser.Mapping.ProcessCrashlog(System.String)"
        );
      ResultTestHelperSubstitution(
          results,
          3,
          "ctor(MainForm, String, String)",
          "ObfuscarMappingParser.StacktraceAnalyerForm.ctor(MainForm, String, String)",
          "ObfuscarMappingParser.StacktraceAnalyerForm.ctor(ObfuscarMappingParser.MainForm, String, String)"
        );
    }
    public void Test4()
    {
      Configs.Instance.SimplifySystemNames = false;
      Mapping mapping = new Mapping(@"Data\Mapping.xml");
      List<SearchResults> results = mapping.ProcessCrashlog(File.ReadAllText(@"Data\test4.txt"));
      Assert.AreEqual(9, results.Count);

      ResultTestHelper(
          results,
          0,
          "void WaitForWaitHandle(WaitHandle)",
          "void System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle)",
          "void System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle)"
        );

      ResultTestHelper(
          results,
          1,
          "void MarshaledInvoke(Control, Delegate, Object[], Boolean)",
          "void System.Windows.Forms.Control.MarshaledInvoke(Control, Delegate, Object[], Boolean)",
          "void System.Windows.Forms.Control.MarshaledInvoke(Control, Delegate, Object[], Boolean)"
        );

      ResultTestHelper(
          results,
          2,
          "void Invoke(Delegate, Object[])",
          "void System.Windows.Forms.Control.Invoke(Delegate, Object[])",
          "void System.Windows.Forms.Control.Invoke(Delegate, Object[])"
        );

      ResultTestHelper(
          results,
          3,
          "void Invoke(Delegate)",
          "void System.Windows.Forms.Control.Invoke(Delegate)",
          "void System.Windows.Forms.Control.Invoke(Delegate)"
        );

      ResultTestHelperOk(
          results,
          4,
          "AntiFreeze.NET",
          "void RefreshPanel(IPanel)",
          "void AntiFreeze.NET.WorkPanel.RefreshPanel(IPanel)",
          "void AntiFreeze.NET.WorkPanel.RefreshPanel(AntiFreeze.Interfaces.Core.IPanel)"
        );

      /*ResultTestHelperOk(
          results,
          5,
          "AntiFreeze.Basic",
          "void AntiFreeze.Basic.TrafficMonitorThread.A(Single, Single, Int64, Int64)",
          "void AntiFreeze.Basic.TrafficMonitorThread.A(Single, Single, Int64, Int64)",
          "void AntiFreeze.Basic.TrafficMonitorThread.A(Single, Single, Int64, Int64)"
        );

      ResultTestHelperOk(
          results,
          6,
          "AntiFreeze.Basic",
          "void AntiFreeze.Basic.TrafficMonitorThread.A(TimeSpan)",
          "void AntiFreeze.Basic.TrafficMonitorThread.A(TimeSpan)",
          "void AntiFreeze.Basic.TrafficMonitorThread.A(TimeSpan)"
        );

      ResultTestHelper(
          results,
          7,
          "void AntiFreeze.Basic.TrafficMonitorThread.l()",
          "void AntiFreeze.Basic.TrafficMonitorThread.l()",
          "void AntiFreeze.Basic.TrafficMonitorThread.l()"
        );*/ // test will not pass, this is a method of superclass but app have no idea about it for now

      ResultTestHelperOk(
          results,
          8,
          "AntiFreeze.Core",
          "void StartThread()",
          "void AntiFreeze.Core.AbstractWorkingThread.StartThread()",
          "void AntiFreeze.Core.AbstractWorkingThread.StartThread()"
        );
    }
Beispiel #26
0
        public SettingsForm(Mapping mapping, ICommandManager commandManager)
        {
            this.mapping = mapping;
            InitializeComponent();

            string vs = null;

            if (mapping != null)
            {
                vs = Configs.Instance.GetRecentProperty(mapping.Filename, Configs.PROPERTY_EDITOR);
            }
            else
            {
                cbApplyVsToProject.Checked = cbApplyVsToProject.Enabled = false;
            }

            if (vs == null)
            {
                vs = Configs.Instance.Editor;
            }
            IVisualStudioInfo selected = VisualStudioDetector.GetVisualStudioInfo(vs);

            if (selected == null)
            {
                selected = VisualStudioDetector.GetHighestVisualStudio();
            }

            foreach (IVisualStudioInfo info in VisualStudioDetector.GetVisualStudios())
            {
                BrokenListItem item = new BrokenListItem(info.Description);
                try
                {
                    Icon icon = Icon.ExtractAssociatedIcon(info.Path);
                    imageList.Images.Add(icon);
                    item.ImageIndex = imageList.Images.Count - 1;
                }
                catch { }
                item.Tag = info;

                blvEditors.Items.Add(item);

                if (info == selected)
                {
                    item.Selected = true;
                }
            }

            cbShowUnicode.Checked         = Configs.Instance.ShowUnicode;
            cbSimplifySystemNames.Checked = Configs.Instance.SimplifySystemNames;
            cbSimplifyNullable.Checked    = Configs.Instance.SimplifyNullable;
            cbSimplifyRef.Checked         = Configs.Instance.SimplifyRef;
            cbGroupByNamespaces.Checked   = Configs.Instance.GroupNamespaces;
            cbGroupByModules.Checked      = Configs.Instance.GroupModules;
            cbUseColumns.Checked          = Configs.Instance.UseColumns;
            cbWatchClipboard.Checked      = Configs.Instance.WatchClipboard;

            EnumHelper.FillCombobox(cbDoubleClick, Configs.Instance.DoubleClickAction);
            EnumHelper.FillCombobox(cbUpdateInterval, Configs.Instance.UpdateHelper.CheckInterval);

            commandSelector.CommandManager = commandManager;
            commandSelector.CommandType    = typeof(Actions);
        }
 public void StatisticsTest()
 {
   Mapping mapping = new Mapping(@"Data\NamingTestMapping.xml");
   Assert.AreEqual(8, mapping.TotalMethodsCount);
   Assert.AreEqual(4, mapping.TotalClassesCount);
   Assert.AreEqual(3, mapping.TotalSubclassesCount);
   Assert.AreEqual(1, mapping.NamespacesCount);
   Assert.AreEqual(1, mapping.ObfuscatedNamespacesCount);
   Assert.AreEqual(1, mapping.ModulesCount);
   Assert.AreEqual(2, mapping.SkippedEntities);
 }