neo-ConfuserEx icon indicating copy to clipboard operation
neo-ConfuserEx copied to clipboard

Renamer broke types implement inherited interface

Open wmjordan opened this issue 5 years ago • 2 comments

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 avatar Jul 31 '19 06:07 wmjordan

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);
}

wmjordan avatar Jul 31 '19 09:07 wmjordan

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.

nathan-chappell avatar Jul 06 '22 10:07 nathan-chappell