From c39a1f7fcc1ca3e1e2178d4f5938bf6099188524 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Sep 2023 13:43:01 -0700 Subject: [PATCH] Add Show GC Info checkbox --- .../Properties/Resources.Designer.cs | 11 +++++++++- ILSpy.ReadyToRun/Properties/Resources.resx | 3 +++ .../Properties/Resources.zh-Hans.resx | 3 +++ ILSpy.ReadyToRun/ReadyToRunDisassembler.cs | 2 +- ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml | 3 +++ ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs | 15 ++++++++++++- ILSpy.ReadyToRun/ReadyToRunOptions.cs | 22 ++++++++++++++++++- 7 files changed, 55 insertions(+), 4 deletions(-) diff --git a/ILSpy.ReadyToRun/Properties/Resources.Designer.cs b/ILSpy.ReadyToRun/Properties/Resources.Designer.cs index f28df710f..5d4bb0f36 100644 --- a/ILSpy.ReadyToRun/Properties/Resources.Designer.cs +++ b/ILSpy.ReadyToRun/Properties/Resources.Designer.cs @@ -95,5 +95,14 @@ namespace ILSpy.ReadyToRun.Properties { return ResourceManager.GetString("ShowUnwindInfo", resourceCulture); } } - } + + /// + /// Looks up a localized string similar to Show GC Info. + /// + public static string ShowGCInfo { + get { + return ResourceManager.GetString("ShowGCInfo", resourceCulture); + } + } + } } diff --git a/ILSpy.ReadyToRun/Properties/Resources.resx b/ILSpy.ReadyToRun/Properties/Resources.resx index 8c6d1ce8c..499c47add 100644 --- a/ILSpy.ReadyToRun/Properties/Resources.resx +++ b/ILSpy.ReadyToRun/Properties/Resources.resx @@ -129,4 +129,7 @@ Show Unwind Info + + Show GC Info + \ No newline at end of file diff --git a/ILSpy.ReadyToRun/Properties/Resources.zh-Hans.resx b/ILSpy.ReadyToRun/Properties/Resources.zh-Hans.resx index 9430c8a3d..9e59d7bc2 100644 --- a/ILSpy.ReadyToRun/Properties/Resources.zh-Hans.resx +++ b/ILSpy.ReadyToRun/Properties/Resources.zh-Hans.resx @@ -129,4 +129,7 @@ 显示展开信息 + + ? + \ No newline at end of file diff --git a/ILSpy.ReadyToRun/ReadyToRunDisassembler.cs b/ILSpy.ReadyToRun/ReadyToRunDisassembler.cs index cfbf5a07d..aa6eb5211 100644 --- a/ILSpy.ReadyToRun/ReadyToRunDisassembler.cs +++ b/ILSpy.ReadyToRun/ReadyToRunDisassembler.cs @@ -50,7 +50,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun ReadyToRunMethod readyToRunMethod = runtimeFunction.Method; WriteCommentLine(readyToRunMethod.SignatureString); - if (readyToRunMethod.GcInfo != null) + if (ReadyToRunOptions.GetIsShowGCInfo(null) && readyToRunMethod.GcInfo != null) { string[] lines = readyToRunMethod.GcInfo.ToString().Split(Environment.NewLine); WriteCommentLine("GC info:"); diff --git a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml b/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml index c11450ef7..609000137 100644 --- a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml +++ b/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml @@ -11,6 +11,7 @@ + @@ -18,5 +19,7 @@ + + \ No newline at end of file diff --git a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs b/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs index a1a9cf689..53da7a71f 100644 --- a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs +++ b/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs @@ -39,6 +39,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun s.DisassemblyFormat = ReadyToRunOptions.GetDisassemblyFormat(settings); s.IsShowUnwindInfo = ReadyToRunOptions.GetIsShowUnwindInfo(settings); s.IsShowDebugInfo = ReadyToRunOptions.GetIsShowDebugInfo(settings); + s.IsShowGCInfo = ReadyToRunOptions.GetIsShowGCInfo(settings); this.DataContext = s; } @@ -51,7 +52,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun public void Save(XElement root) { Options s = (Options)this.DataContext; - ReadyToRunOptions.SetDisassemblyOptions(root, s.DisassemblyFormat, s.IsShowUnwindInfo, s.IsShowDebugInfo); + ReadyToRunOptions.SetDisassemblyOptions(root, s.DisassemblyFormat, s.IsShowUnwindInfo, s.IsShowDebugInfo, s.IsShowGCInfo); } } @@ -86,6 +87,18 @@ namespace ICSharpCode.ILSpy.ReadyToRun } } + private bool isShowGCInfo; + + public bool IsShowGCInfo { + get { + return isShowGCInfo; + } + set { + isShowGCInfo = value; + OnPropertyChanged(nameof(IsShowGCInfo)); + } + } + private string disassemblyFormat; public string DisassemblyFormat { diff --git a/ILSpy.ReadyToRun/ReadyToRunOptions.cs b/ILSpy.ReadyToRun/ReadyToRunOptions.cs index 22fc68639..365d1dd9a 100644 --- a/ILSpy.ReadyToRun/ReadyToRunOptions.cs +++ b/ILSpy.ReadyToRun/ReadyToRunOptions.cs @@ -87,12 +87,32 @@ namespace ICSharpCode.ILSpy.ReadyToRun } } - public static void SetDisassemblyOptions(XElement root, string disassemblyFormat, bool isShowUnwindInfo, bool isShowDebugInfo) + public static bool GetIsShowGCInfo(ILSpySettings settings) + { + if (settings == null) + { + settings = ILSpySettings.Load(); + } + XElement e = settings[ns + "ReadyToRunOptions"]; + XAttribute a = e.Attribute("IsShowGCInfo"); + + if (a == null) + { + return false; + } + else + { + return (bool)a; + } + } + + public static void SetDisassemblyOptions(XElement root, string disassemblyFormat, bool isShowUnwindInfo, bool isShowDebugInfo, bool isShowGCInfo) { XElement section = new XElement(ns + "ReadyToRunOptions"); section.SetAttributeValue("DisassemblyFormat", disassemblyFormat); section.SetAttributeValue("IsShowUnwindInfo", isShowUnwindInfo); section.SetAttributeValue("IsShowDebugInfo", isShowDebugInfo); + section.SetAttributeValue("IsShowGCInfo", isShowGCInfo); XElement existingElement = root.Element(ns + "ReadyToRunOptions"); if (existingElement != null) {