vlingo-net / xoom-net-actors

Type safe Actor Model toolkit for reactive concurrency and resiliency using C# and other .NET languages.
Mozilla Public License 2.0
39 stars 18 forks source link

ProxyGenerator enhancements #53

Closed zpbappi closed 4 years ago

zpbappi commented 5 years ago

Currently the Vlingo.Actors.ProxyGenerator class has some limitations. We will need to enhance it to overcome these.

It cannot create a proxy for an inner interface contained within a class. It would create a source that would fail compilation by the Vlingo.Common.DynaCompiler.Compile()

public class MyClass
{
  public interface IMyInterface
  {
    void DoSomething();
  }
}

public class MyActor : Actor, MyClass.IMyInterface
{
  public void DoSomething() { }
}

For the code above, the following setup will fail

var world = World.StartWithDefault("test-world");
// it fails in the line below
var actor = world.ActorFor<MyClass.IMyInterface>(Definition.Has<MyActor>(Definition.NoParameters, "actor"));
Assert.NotNull(actor);

It fails similarly if the interface is not inner, but it references to any inner type.

public class MyOuterClass
{
  public class MyInnerClass
  {
  }
}

public interface IMyInterface
{
  void DoSomethingWith(MyOuterClass.MyInnerClass obj);
}

public class MyActor : Actor, IMyInterface
{
  public void DoSomethingWith(MyOuterClass.MyInnerClass obj) { }
}

For the code above, the following setup will fail

var world = World.StartWithDefault("test-world");
// it fails in the line below
var actor = world.ActorFor<IMyInterface>(Definition.Has<MyActor>(Definition.NoParameters, "actor"));
Assert.NotNull(actor);
VaughnVernon commented 5 years ago

@zpbappi @tjaskula In Java I used the naming convention OuterInner__Proxy to avoid naming issues. It has worked well so far.