Skip to content

Commit

Permalink
Add debugger display attributes to the generator context types (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 authored Sep 13, 2024
1 parent 1eacadb commit f808c31
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Il2CppInterop.Generator/Contexts/AssemblyRewriteContext.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Diagnostics;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using Il2CppInterop.Generator.Extensions;
using Il2CppInterop.Generator.Utils;

namespace Il2CppInterop.Generator.Contexts;

[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
public class AssemblyRewriteContext
{
// TODO: Dispose
Expand Down Expand Up @@ -148,4 +150,9 @@ public TypeRewriteContext GetTypeByName(string name)
{
return myNameTypeMap.TryGetValue(name, out var result) ? result : null;
}

private string GetDebuggerDisplay()
{
return NewAssembly.FullName;
}
}
6 changes: 6 additions & 0 deletions Il2CppInterop.Generator/Contexts/FieldRewriteContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Il2CppInterop.Generator.Contexts;

[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
public class FieldRewriteContext
{
private static readonly string[] MethodAccessTypeLabels =
Expand Down Expand Up @@ -84,4 +85,9 @@ private string UnmangleFieldName(FieldDefinition field, GeneratorOptions options

return unmangleFieldNameBase;
}

private string GetDebuggerDisplay()
{
return DeclaringType.NewType.FullName + "::" + UnmangledName;
}
}
7 changes: 7 additions & 0 deletions Il2CppInterop.Generator/Contexts/MethodRewriteContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using AsmResolver.DotNet;
Expand All @@ -10,6 +11,7 @@

namespace Il2CppInterop.Generator.Contexts;

[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
public class MethodRewriteContext
{
private static readonly string[] MethodAccessTypeLabels =
Expand Down Expand Up @@ -309,4 +311,9 @@ private bool ParameterSignatureMatchesThis(MethodRewriteContext otherRewriteCont

return true;
}

private string GetDebuggerDisplay()
{
return NewMethod.FullName;
}
}
9 changes: 8 additions & 1 deletion Il2CppInterop.Generator/Contexts/TypeRewriteContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
Expand All @@ -6,6 +7,7 @@

namespace Il2CppInterop.Generator.Contexts;

[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
public class TypeRewriteContext
{
public enum TypeSpecifics
Expand All @@ -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
Expand Down Expand Up @@ -180,4 +182,9 @@ public MethodRewriteContext GetMethodByOldMethod(MethodDefinition method)

return null;
}

private string GetDebuggerDisplay()
{
return NewType.FullName;
}
}

0 comments on commit f808c31

Please sign in to comment.