forked from yck1509/ConfuserEx
-
-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathBAMLTypeReference.cs
40 lines (33 loc) · 1.27 KB
/
BAMLTypeReference.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Text;
using Confuser.Core;
using Confuser.Renamer.BAML;
using dnlib.DotNet;
namespace Confuser.Renamer.References {
internal sealed class BAMLTypeReference : INameReference<TypeDef> {
readonly TypeInfoRecord rec;
readonly TypeSig sig;
public bool ShouldCancelRename => false;
public BAMLTypeReference(TypeSig sig, TypeInfoRecord rec) {
this.sig = sig;
this.rec = rec;
}
public bool UpdateNameReference(ConfuserContext context, INameService service) {
if (string.Equals(rec.TypeFullName, sig.ReflectionFullName, StringComparison.Ordinal)) return false;
rec.TypeFullName = sig.ReflectionFullName;
return true;
}
/// <inheritdoc />
public bool DelayRenaming(INameService service, IDnlibDef currentDef) => false;
public override string ToString() => ToString(null);
public string ToString(INameService nameService) {
var builder = new StringBuilder();
builder.Append("BAML Type Reference").Append("(");
builder.Append("Type Info Record").Append("(").AppendHashedIdentifier("Name", rec.TypeFullName).Append(")");
builder.Append("; ");
builder.Append("Type Signature").Append("(").AppendHashedIdentifier("Name", sig.ReflectionFullName).Append(")");
builder.Append(")");
return builder.ToString();
}
}
}