Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamer broke types implement inherited interface #55

Open
wmjordan opened this issue Jul 31, 2019 · 2 comments
Open

Renamer broke types implement inherited interface #55

wmjordan opened this issue Jul 31, 2019 · 2 comments

Comments

@wmjordan
Copy link

wmjordan commented Jul 31, 2019

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 wmjordan changed the title Renamer broke types implement inherited generic interface Renamer broke types implement inherited interface Jul 31, 2019
@wmjordan
Copy link
Author

wmjordan commented Jul 31, 2019

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
Copy link

I've found one of the offending lines:

target.MethodSig = new Importer(method.Module, ImporterOptions.TryToUseTypeDefs).Import(method.MethodSig);

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants