Drakulix / ScrollsModLoader

A Mod Loader Framework for the game "Scrolls" by Mojang
www.scrollsguide.com/summoner
GNU Lesser General Public License v2.1
15 stars 9 forks source link

Overloaded Methods do not work properly #5

Open MaPePeR opened 10 years ago

MaPePeR commented 10 years ago

I found several places in the code, where a method is only identified by its DeclaringType and its Name.

This might result in overloaded Methods not be hookable, because always the first method with matching name and type is hooked.

(confirmed this now)

MaPePeR commented 10 years ago

Ok, the problem turns out a bit different, than i thought: It only occurs when there are 2 mods which hook different version of the overloaded method. Then both mods will be invoked for both method signatures. (Confirmed this with some test mods)

The reason for this is, that the ScrollsFilter-class only patches/weaves methods that match the full signature.

Drakulix commented 10 years ago

so we need a way to generate a complete signature out of the method, instead of it's name. Something like method.returntype.name + method.name + for (string argument in method.arguments) { +argument.type.name } would be enough, don't you think so? Maybe we can add this through an extension method?

MaPePeR commented 10 years ago

yes. exactly.

I think MethodReference.FullName should work.(`MethodDefinition inherits from it)

The return type is not needed, because methods are only unique in declaringType + name + arguments.