aa55h
aa55h
Explore posts from servers
CC#
Created by aa55h on 10/20/2024 in #help
Mono.Cecil TypeReference modifies TypeDefinition
i have this code:
MemberReference member = instruction.Operand;
if (Mappings.GetType(member.DeclaringType.Name, DefaultNamespace) is TypeDefinitionEntry typeDefinition)
{
WriteIfVerbose($"Remapping reference to {member.Name}'s type {member.DeclaringType.Name} -> {typeDefinition[TargetNamespace]}");
member.DeclaringType.Name = typeDefinition.Names[TargetNamespace];
}
MemberReference member = instruction.Operand;
if (Mappings.GetType(member.DeclaringType.Name, DefaultNamespace) is TypeDefinitionEntry typeDefinition)
{
WriteIfVerbose($"Remapping reference to {member.Name}'s type {member.DeclaringType.Name} -> {typeDefinition[TargetNamespace]}");
member.DeclaringType.Name = typeDefinition.Names[TargetNamespace];
}
the problem is the second line in the if statement body, it seems like it also modifies the class the member belongs to, and not only the reference to it, any idea why?
8 replies