Facepunch / sbox-issues

180 stars 12 forks source link

WrappedMethod<T> always trigger a codegen error #7497

Closed bub-bl closed 6 days ago

bub-bl commented 1 week ago

Describe the bug

When using the WrappedMethod struct, the compilator always trigger an error. The problem is only with WrappedMethod The printed error: 'WrappedMethod' does not contain a definition for 'Object'

To Reproduce

Take the following code:

public static class InternalTest
{
    public static bool __test_call_Wrapper( WrappedMethod<bool> m )
    {
        Log.Info( "Before" );
        return m.Resume();
    }
}

[AttributeUsage( AttributeTargets.Method )]
[CodeGenerator( CodeGeneratorFlags.WrapMethod | CodeGeneratorFlags.Static,
    "InternalTest.__test_call_Wrapper" )]
public sealed class CallAttribute : Attribute
{
}

Put this function in a script or whatever. You should have a compilation error

        [Call]
    private static bool TestCall()
    {
        Log.Info("After");
        return true;
    }

Expected behavior

We should have the ability to use the WrappedMethod struct in codegen

Media/Files

No response

Additional context

No response