Reflexil icon indicating copy to clipboard operation
Reflexil copied to clipboard

Renaming class with inherited classes do not rename name of inherited from

Open NiKiZe opened this issue 8 years ago • 5 comments

Lets say we have

namespace a {
  public class a : object {}
  public class b : a {}
}

and use Reflxil rename (running from ILSpy) to change a.a into ns_a.class_a, PEVerify fails on a.b because inherit on name was not changed and is still left as a

I believe this happens even if namespace stays the same, but wanted to cover the namespace change case as well.

NiKiZe avatar Feb 16 '16 22:02 NiKiZe

It works perfectly on my side. Can you give me a real repro ? with an assembly and your repro steps.

What version of ILSpy/Reflexil are you using?

sailro avatar Feb 18 '16 18:02 sailro

Sorry for delayed response, this is for a hobby project so working on it when times allow. Running ILSpy version 2.3.1.1855 Reflexil v2.1

Full reproducable codesample: (codestyle to reduce lines in issue)

namespace a.a
{
    public class a : object {
        public a() { }
        public int testAccess() { return 42; }
    }
    public class b : a {
        public b() { }
        public int a() { return 0; }
    }
    public class testAccessor {
        public static int testAccess = new b().testAccess();
    }
}

This is compiled as an .NET 2.0 Dll And then trying to rename class a and running verify results in (translated from localized message..) "unable to match token: a.a.testAccessor::cctor" b still inherits from a and not from what a was renamed to.

NiKiZe avatar Mar 13 '16 16:03 NiKiZe

Reproduced. But not always.... Sometimes it works.

If you select b then go to a to rename it, it will fail. If you run ILSpy, go to a to rename it, it will work.

Perhaps a cache issue, investigating.

sailro avatar Mar 31 '16 17:03 sailro

Same behaviour with Reflector

sailro avatar Mar 31 '16 17:03 sailro

Ah, interesting, thanks for investigating, at-least now I know how it hopefully might be avoided, but I know it would be easier to debug/fix if there was a more consistent behavior.

NiKiZe avatar Mar 31 '16 17:03 NiKiZe