From e53e2c9bad62435dec0dbfcbe4a5ae7ac90cfb97 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:58:39 -0700 Subject: [PATCH] Add debugger display attributes to the generator context types --- .../Contexts/AssemblyRewriteContext.cs | 7 +++++++ Il2CppInterop.Generator/Contexts/FieldRewriteContext.cs | 6 ++++++ Il2CppInterop.Generator/Contexts/MethodRewriteContext.cs | 7 +++++++ Il2CppInterop.Generator/Contexts/TypeRewriteContext.cs | 9 ++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Il2CppInterop.Generator/Contexts/AssemblyRewriteContext.cs b/Il2CppInterop.Generator/Contexts/AssemblyRewriteContext.cs index e6e3afab..01a714cf 100644 --- a/Il2CppInterop.Generator/Contexts/AssemblyRewriteContext.cs +++ b/Il2CppInterop.Generator/Contexts/AssemblyRewriteContext.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using AsmResolver.DotNet; using AsmResolver.DotNet.Signatures; using Il2CppInterop.Generator.Extensions; @@ -5,6 +6,7 @@ namespace Il2CppInterop.Generator.Contexts; +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public class AssemblyRewriteContext { // TODO: Dispose @@ -148,4 +150,9 @@ public TypeRewriteContext GetTypeByName(string name) { return myNameTypeMap.TryGetValue(name, out var result) ? result : null; } + + private string GetDebuggerDisplay() + { + return NewAssembly.FullName; + } } diff --git a/Il2CppInterop.Generator/Contexts/FieldRewriteContext.cs b/Il2CppInterop.Generator/Contexts/FieldRewriteContext.cs index 0d890367..73817a15 100644 --- a/Il2CppInterop.Generator/Contexts/FieldRewriteContext.cs +++ b/Il2CppInterop.Generator/Contexts/FieldRewriteContext.cs @@ -7,6 +7,7 @@ namespace Il2CppInterop.Generator.Contexts; +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public class FieldRewriteContext { private static readonly string[] MethodAccessTypeLabels = @@ -84,4 +85,9 @@ private string UnmangleFieldName(FieldDefinition field, GeneratorOptions options return unmangleFieldNameBase; } + + private string GetDebuggerDisplay() + { + return DeclaringType.NewType.FullName + "::" + UnmangledName; + } } diff --git a/Il2CppInterop.Generator/Contexts/MethodRewriteContext.cs b/Il2CppInterop.Generator/Contexts/MethodRewriteContext.cs index 3eae86a9..d67694f8 100644 --- a/Il2CppInterop.Generator/Contexts/MethodRewriteContext.cs +++ b/Il2CppInterop.Generator/Contexts/MethodRewriteContext.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using System.Runtime.CompilerServices; using System.Text; using AsmResolver.DotNet; @@ -10,6 +11,7 @@ namespace Il2CppInterop.Generator.Contexts; +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public class MethodRewriteContext { private static readonly string[] MethodAccessTypeLabels = @@ -302,4 +304,9 @@ private bool ParameterSignatureMatchesThis(MethodRewriteContext otherRewriteCont return true; } + + private string GetDebuggerDisplay() + { + return NewMethod.FullName; + } } diff --git a/Il2CppInterop.Generator/Contexts/TypeRewriteContext.cs b/Il2CppInterop.Generator/Contexts/TypeRewriteContext.cs index 8ae63c4f..6b017c25 100644 --- a/Il2CppInterop.Generator/Contexts/TypeRewriteContext.cs +++ b/Il2CppInterop.Generator/Contexts/TypeRewriteContext.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using AsmResolver.DotNet; using AsmResolver.DotNet.Signatures; using AsmResolver.PE.DotNet.Metadata.Tables; @@ -6,6 +7,7 @@ namespace Il2CppInterop.Generator.Contexts; +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public class TypeRewriteContext { public enum TypeSpecifics @@ -26,7 +28,7 @@ public enum TypeSpecifics public readonly bool OriginalNameWasObfuscated; #nullable disable - // OriginalType is null for unstripped types, but we don't want to warn anywhere, + // OriginalType is null for unstripped types, but we don't want to warn anywhere, // including in the constructor, so we disable all null tracking for this field. public readonly TypeDefinition OriginalType; #nullable enable @@ -180,4 +182,9 @@ public MethodRewriteContext GetMethodByOldMethod(MethodDefinition method) return null; } + + private string GetDebuggerDisplay() + { + return NewType.FullName; + } }