From 54a742f3f5a66de37d931a9da348eb5c4610bd18 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 7 Mar 2020 19:54:57 +0100 Subject: [PATCH] Metadata Explorer: Display blob contents of custom debug information in tooltip. --- .../Metadata/MetadataExtensions.cs | 12 ++++++++++++ .../CustomDebugInformationTableTreeNode.cs | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs b/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs index d83b9bb3f..8d304cc29 100644 --- a/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs +++ b/ICSharpCode.Decompiler/Metadata/MetadataExtensions.cs @@ -101,6 +101,18 @@ namespace ICSharpCode.Decompiler.Metadata return sb.ToString(); } + public static string ToHexString(this BlobReader reader) + { + StringBuilder sb = new StringBuilder(reader.Length * 3); + for (int i = 0; i < reader.Length; i++) { + if (i == 0) + sb.AppendFormat("{0:X2}", reader.ReadByte()); + else + sb.AppendFormat("-{0:X2}", reader.ReadByte()); + } + return sb.ToString(); + } + public static IEnumerable GetTopLevelTypeDefinitions(this MetadataReader reader) { foreach (var handle in reader.TypeDefinitions) { diff --git a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs index bffe6abfc..bbe0b966b 100644 --- a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs +++ b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs @@ -138,7 +138,9 @@ namespace ICSharpCode.ILSpy.Metadata public string ValueTooltip { get { - return null; + if (debugInfo.Value.IsNil) + return ""; + return metadata.GetBlobReader(debugInfo.Value).ToHexString(); } }