Skip to content

ActLike() fails with explicit interface implementation #36

@piedar

Description

@piedar

I'm not sure if this is expected behavior.

interface IDo
{
    void Do();
}

sealed class DoNothing : IDo
{
    void IDo.Do() { }
}
class TheDoNothing
{
    [Test]
    public void CanActLike()
    {
        var instance = new DoNothing();
        var acting = instance.ActLike<IDo>();
        acting.Do(); // throws RuntimeBinderException
    }
}

I read about Dynamitey UsagePrivate but this produces the same result.

class TheDoNothing
{
    [Test]
    public void CanActLike()
    {
        var instance = new DoNothing();
        var context = new InvokeContext(instance, typeof(IDo));
        var acting = context.ActLike<IDo>();
        acting.Do(); // throws RuntimeBinderException
    }
}

Obviously this a toy example, but I'm running into real issues when trying to do something similar using DynamicActLike() with an interface type known only at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions