XenocodeRCE / neo-ConfuserEx

Updated ConfuserEX, an open-source, free obfuscator for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
746 stars 89 forks source link

Renamer broke types implement inherited interface #55

Open wmjordan opened 4 years ago

wmjordan commented 4 years ago

Describe the bug An exception Unhandled Exception: System.TypeLoadException: Signature of the body and declaration in a method implementation do not match. will be thrown.

To Reproduce Use the following project and the Normal preset to reproduce the issue. ConsoleApp1.zip

Related code:

class C<TItem> : S<TItem>
{
    public TItem GetT(int key)=> default(TItem);
}
interface S<TItem> : I<int, TItem> { }
interface I<TKey, TItem> {
    TItem GetT(int key);
}
wmjordan commented 4 years ago

And there is a bug when renaming an abstract method which is imported from external assembly.

Please use the following project to reproduce the issue: ConsoleApp1.zip

Expected result: CanExtend method in class C should not get renamed.

Related code:

class C<TItem> : B, S<TItem>
{
    public TItem GetT(int key)=> default(TItem);

    public override bool CanExtend(object extendee) {
        throw new NotImplementedException();
    }
}
[Serializable]
abstract class B : System.ComponentModel.IExtenderProvider
{
    public abstract bool CanExtend(object extendee);
}
interface S<TItem> : I<int, TItem> { }
interface I<TKey, TItem> {
    TItem GetT(int key);
}
nathan-chappell commented 2 years ago

I've found one of the offending lines:

https://github.com/XenocodeRCE/neo-ConfuserEx/blob/788997184ba573b71400573dbcabbf9b55f71959/Confuser.Renamer/References/OverrideDirectiveReference.cs#L54

I don't know what the purpose of this line is, but when I watch it in debug I see the method signature of the target go from

  1. containing correct indices for generic parameters to
  2. replacing some generic parameters with their instantiations

When I get rid of it, the obfuscated dll works fine. I don't know if that line is actually doing anything important, but it's certainly also breaking something.