ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.52k stars 362 forks source link

IL2CPP crash when using reflection baking #648

Open EusthEnoptEron opened 5 years ago

EusthEnoptEron commented 5 years ago

It seems IL2CPP does not like it when Zenject tinkers with compiler generated classes; when using async/await in any class that is processed by Zenject's reflection baking, Il2CPP will crash with an exception in the generated C++ code.

error C2664: 'void ValueType__ctor_m091BDF02E011A41101A74AABB803417EE40CA5B7(RuntimeObject *,const RuntimeMethod *)': cannot convert argument 1 from 'U3CDoSomethingU3Ed__2_t673479742037832A3C72A1D9F5D1FE36700A64B0 *' to 'RuntimeObject *'

Currently, our workaround is to filter out generated classes with a RegExp that catches all unspeakable names. Maybe this would be a good default, unless there is a use case where you would want to inject something into those?

Tested with 2018.3.14f1 and 2019.1.8f.

Here's a minimal project to reproduce the issue: AsyncAwait.zip