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

Add additional check on constructor parameters type when creating an actor #91

Closed tjaskula closed 3 years ago

tjaskula commented 3 years ago

ActorFactory doesn't take into account the types of parameters when creating an actor but only the number of the constructor parameters. For example those two constructors get mismatched:

public InMemoryJournalActor(IDispatcher<Dispatchable<TEntry, TState>> dispatcher)
            => _journal = new InMemoryJournal<T, TEntry, TState>(dispatcher, Stage.World);

public InMemoryJournalActor(IEnumerable<IDispatcher<Dispatchable<TEntry, TState>>> dispatchers)
    => _journal = new InMemoryJournal<T, TEntry, TState>(dispatchers, Stage.World);

The code responsible that needs to be fixed:

foreach (var ctor in definition.Type!.GetConstructors())
{
    if (ctor.GetParameters().Length != definitionParameterCount)
        continue;

    actor = Start(ctor, address, definition, logger);

    if(actor != null)
    {
        break;
    }
}