dnlib
dnlib copied to clipboard
Why does dnlib compare two MemberDef by name?
Why a == b
is not enough?
class Program
{
int a;
int b;
}
Rename b to a by dnSpy, then SigCompare will think it's the same field, but it's not in fact.
It's useful when you open the same assembly but two different versions and need to compare defs. Reference equality is not what you want when comparing types A
from both assemblies since they should be considered equal.
However it causes problems like you mentioned above.
This is a breaking change so we could change the default in v4 and add an option to use the old behavior if needed.
SigComparer could also be updated to check if they're in the same module and if so, use reference equality in that case.
@wtfsck This one should be marked as v4, it's important for dnSpy analyzer, since many obfuscators will generate duplicate names.
PRs welcome!