Skip to content

Convert Il2Cpp Delegates to System Delegates in Method Signatures #195

@ds5678

Description

@ds5678

In theory, all Il2Cpp Action and Func delegates in method signatures could be converted to their System counterparts. This would be emitted as a separate overload, rather than a direct substitution. It synergizes well with #148 and allows more system interfaces to be implemented, such as INotifyCompletion (which was the incentive for #133).

public Il2CppSystem.Action Method(Il2CppSystem.Action normalParam, in Il2CppSystem.Action inParam, out Il2CppSystem.Action outParam);

public System.Action Method(System.Action normalParam, in System.Action inParam, out System.Action outParam)
{
    // Conversions are shown explicitly here for clarity, even though they're actually implicit
    var normalParamIl2Cpp = (Il2CppSystem.Action)normalParam;
    var inParamIl2Cpp = (Il2CppSystem.Action)inParam;
    Il2CppSystem.Action result = Method(normalParamIl2Cpp, in inParamIl2Cpp, out Il2CppSystem.Action outParamIl2Cpp);
    outParam = (System.Action)outParamIl2Cpp;
    return (System.Action)result;
}

In theory, ref parameters could also be supported.

public void Method(ref Il2CppSystem.Action param);

public void Method(ref System.Action param)
{
    // Conversions are shown explicitly here for clarity, even though they're actually implicit
    var paramIl2Cpp = (Il2CppSystem.Action)param;
    Method(ref paramIl2Cpp);
    param = (System.Action)paramIl2Cpp;
}

Property accessors and conversion operators should be excluded. Converting event methods might enable #163 to become a reality.

Discussed briefly here: #133 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    generationRelated to assembly generation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions