Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Scripting: Base interfaces' method can not be called in Globals object #30947

Open
pongba opened this issue Nov 4, 2018 · 1 comment
Open

Comments

@pongba
Copy link

pongba commented Nov 4, 2018

Version Used:
Latest

Steps to Reproduce:
Define the Globals type as such:

public interface IGlobals
{
    bool Foo();
}

public interface IGlobals2 : IGlobals
{
    bool Bar();
}

Now create the script with IGlobals2 as the injected global object type:

CSharpScript.Create<int>("Foo();", globalsType: typeof(IGlobals2),...);

Expected Behavior:
script should compile and work.

Actual Behavior:
error CS0120: An object reference is required for the non-static field, method, or property 'IGlobals.Foo'

However, if instead we use class inheritence, it will work:

public class Globals
{
    public void Foo() { }
}
public class Globals2 : public Globals
{
    public void Bar() { }
}

CSharpScript.Create<int>("Foo();", globalsType: typeof(Globals2),...);
@pongba
Copy link
Author

pongba commented Nov 7, 2018

@jinujoseph is this confirmed a bug or an expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants