Lokad / ILPack

Serialize .NET Core assemblies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

With Patch/Fix: Missing Generic Type arguments in OpCodes.Call(x)

mf-RDP opened this issue · comments

Hi Joannès,

I found a bug and fixed this, however, this time the fix is a bit more sophisticated, so I ask you kindly to review.
I tried to submit a PR but did not find out how, with Github.

Let me explain:

  1. You have an ModuleBuilder and in this single module you create
  • A generic type inheriting from an external, also generic type, with generic params 1:1
  • Another type in this in-memory-module that inherits from this type before and calls methods, for these calls, the 'this pointer' of course must be the constructed type, not the open type.

Currently, with ILPack this is failing. Please see screenshot below with wrongly generated IL, Type arguments are missing

missing_type_inst

To fix, I did the following:

  • changed MethodBodyWriter to make sure constructed types are written, I extended your interface and added some TryGetMethodDefinitionConstructedType etc.

  • I changed IsReferencedType. For this, I ask you kindly to review as this new approach is also just a best guess :)

Good news is, all tests are passing as per before and the problem is gone. I write quite large assemblies, referencing and inheriting e.g. all types in netstandard.

fixed_missing_type_inst

PS: Please let me know if you need something. It may be this problem also exists for generic methods, I will check this at a later time.

Many Thanks

Sascha
ILPack.zip

Thanks a lot. Could you submit a regular pull request? I have very little time those days (Lokad is growing), and it really facilitate the process on my side. Best regards, Joannes