-
Notifications
You must be signed in to change notification settings - Fork 106
Description
Context
This is a stronger form of #141. In order to have more perfect unstripping, we need to remove all special treatment for corlib primitives. They will no longer be used in place of their Il2Cpp variants.
Implementation Details
- The Il2Cpp primitives will need bidirectional implicit conversion operators to their System counterparts.
- During unstripping, instance methods can be called on these primitives. Currently, this is limited to static methods.
IL Complications
Any IL instruction directly related to numeric operations on the stack, eg ldc.i4, may require special handling. This could become quite complicated.
Alternatives
Do Nothing
We could allow this to fail at runtime with missing method exceptions. That is not ideal, but it is a valid approach until #141 is implemented, which will break references that involve string. Similarly, this approach is not compatible with #173.
Note: there may be subtle differences between the Unity implementation and the CoreCLR implementation. For example, I think floating point serialization is slightly different.
Fail When Primitive Instance Methods Are Referenced
This isn't ideal, but it's completely compatible with #141 and #173.
Fail When The Signature Would Be Different
Same as the previous option, except the code is smarter.
Call The Instance Methods Anyway
As long as the runtime doesn't complain, it should be safe to call the instance methods on the numeric primitives, since they have the same memory layout. For example, ILSpy shows this as:
((Int32*)(&index))->ToString()Generate Extension Methods
We could generate extension methods that wrap the Il2Cpp instance methods. It would look roughly like this: