Giter VIP home page Giter VIP logo

xoom-net-actors's People

Contributors

falamarzijahromi avatar jamesmh avatar mihaj avatar tjaskula avatar vaughnvernon avatar waelemara avatar zpbappi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xoom-net-actors's Issues

System.TypeLoadException: Method 'AndThenTo' does not have an implementation.

This happens with the following line World.StartWithDefault("test-request-response-channel");

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Method 'AndThenTo' in type 'Vlingo.Common.ResultCompletes`1' from assembly 'Vlingo.Actors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at Vlingo.Actors.Actor..ctor()
   at Vlingo.Actors.PrivateRootActor..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Vlingo.Actors.ActorFactory.ActorFor(Stage stage, Actor parent, Definition definition, IAddress address, IMailbox mailbox, ISupervisor supervisor, ILogger logger)
   at Vlingo.Actors.Stage.CreateRawActor(Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger)

Target netstandard2.0 et netstandard2.1

The goal is to use new C#8 features like default interface implementation and nullable types which helps a lot porting java code to .net.

  • Change TargetFramework to TargetFrameworks in csproj, listing netstandard2.0;netstandard2.1

  • Add <LangVersion>latest</LangVersion>

  • Add <Nullable>enable</Nullable>

  • Change TargetFramework to TargetFrameworks in csproj, listing netcoreapp3.0 for test project

  • Finish #64

  • Finish #65

Proxy generator should include full names for types resolution

The current implementation generates the code in the form:

LocalMessage<Node>

but this leads to many conflicts where for example we have a namespace clash with type name like for the type Vlingo.Wire.Node.Node. The generated proxy LocalMessage<Node> obviously doesn't compile if we have using Vlingo.Wire.Node at the beginning of the file.

It would be much better and less error prone if instead of relying on using directives we just put the full name spaces like

LocalMessage<Vlingo.Wire.Node.Node>

They are just proxy, so we don't care if this looks bad but at least it will work in every case. Now it's not working for many proxies that I have to fix manually.

Support C# properties in generated proxies

For example a protocol like that:

public interface IEntity1
    {
        ICompletes<Entity1State> DefineWith(string name, int age);

        ICompletes<Entity1State> Current { get; }

        void ChangeName(string name);

        void IncreaseAge();
    }

Will not generate the correct handler for Current property because they are not supported

Change Appveyor configuration

Related to #66

Make changes according to this template

version: 0.0.{build}
image:
  - Visual Studio 2019
  - Ubuntu
configuration: Release
skip_commits:
  message: /.*\[ci\-skip\].*/ 
before_build:
  - dotnet restore src/Vlingo.UUID.sln
build:
  project: src/Vlingo.UUID.sln
  verbosity: minimal
  publish_nuget: true
test_script:
  - dotnet test src/Vlingo.UUID.Tests
deploy:
  - provider: NuGet
    api_key:
      secure: keYt7U6hDEIBzKLfVMts/6deGh0bqJdcjhlO2mWEJ04SRIS0Y6+e3EjszsRqq5nJ
    skip_symbols: true
    artifact: /.*\.nupkg/
    on:
      branch: master
notifications:
  - provider: Webhook
    url: https://webhooks.gitter.im/e/2b56d1ca84637acb9ee8
    method: POST
    on_build_success: true
    on_build_failure: true
    on_build_status_changed: true

Support Task<T> In ProxyGenerator

For anyone with a spare hour or so, this is a pretty simple contribution.

Support Task<T> as a valid type in the ProxyGenerator. Inside the ProxyGenerator you will see the current Completes<T> support, and this type can be added along side it pretty easily.

NOTE: Task<T> will not be used for vlingo-net-platform internals or public APIs. We will continue to use Completes<T> for core vlingo-net-platform protocols. Consumers will for sure want to use Task<T> as a return type in their protocols. We will provide sufficient warnings in the docs regarding the use of Task<T>, but some will think it's a great idea and insist on its support.

Type-safe constructor for Actor creation

Today we crate the actor by the following way:

var definition =
                Definition.Has<InboundStreamActor>(Definition.Parameters(interest, addressType, reader, probeInterval),$"{inboundName}-inbound");
var inboundStream = stage.ActorFor<IInboundStream>(definition);

The goal would be to create the actor in the type-safe manner. Why ? Because it easier to be guided by the compiler what parameters to pass in the actor based on the type of actor. Instead we could do the following

var inboundStream = stage.ActorFor<IInboundStream>(() => new InboundStreamActor(interest, addressType, reader, probeInterval),$"{inboundName}-inbound"))

For that we would need to leverage creation through expressions like:

ActorFor<TActor>(Expression<Func<TActor>> factor)

For reference on JVM implementation (for impacted files rather than implementation details) : vlingo/xoom-actors@141f31b

Investigate randomly failing tests after new BasicCompletes implementation

I have noticed that there is still a slight issue as it comes to the execution of the pipeline in the multi threaded environment. These are not blocking but the investigation should be done along with a fix to be sure that everything behaves consistently.

On CI server:

Locally on Windows machine:

  • TestAfterAndThenCompletesForSideEffects
System.NullReferenceException : Object reference not set to an instance of an object.
   at Vlingo.Actors.Tests.CompletesActorProtocolTest.TestAfterAndThenCompletesForSideEffects() in C:\Sources\GitHub\vlingo-net-actors\src\Vlingo.Actors.Tests\CompletesActorProtocolTest.cs:line 48
  • TestReturnsCompletesForSideEffects freezes
  • TestSupplierProtocol freezes
  • TestTwoArgConsumerProtocol.

I suspect those might be the problem of continuation not being executed immediately if the outcome is set for the main continuation.

ProxyGenerator doesn't support generic methods

Non generic interface with a generic method is not supported and fails at compilation. The example of the interface:

public interface IGenericMethod
    {
        void Handle<T>(string name, Action<T> consumer) where T : GenericHandler;
    }

Generation of the proxy fails with the following error:

vlingo-net/actors[Debug]: vlingo-net/actors: Generating proxy for main: IGenericMethod
Dynamically generated class source for Vlingo.Actors.Tests.GenericMethod__Proxy did not compile because: The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
   at Vlingo.Common.Compiler.DynaCompiler.Compile(Input input)
vlingo-net/actors[Debug]: vlingo-net/actors: Generating proxy for test: IGenericMethod
Dynamically generated class source for Vlingo.Actors.Tests.GenericMethod__Proxy did not compile because: The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
   at Vlingo.Common.Compiler.DynaCompiler.Compile(Input input)
Actor proxy IGenericMethod not created for main or test: Actor proxy IGenericMethod not created because: Dynamically generated class source did not compile: Vlingo.Actors.Tests.GenericMethod__Proxy
   at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, String targetClassName, String lookupTypeName) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 91
   at Vlingo.Actors.ActorProxy.CreateFor(Type protocol, Actor actor, IMailbox mailbox) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 45
   at Vlingo.Actors.ActorProxy.CreateFor[T](Actor actor, IMailbox mailbox) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 19
   at Vlingo.Actors.Stage.ActorProxyFor[T](Actor actor, IMailbox mailbox) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/Stage.cs:line 450
   at Vlingo.Actors.Stage.ActorProtocolFor[T](Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/Stage.cs:line 394
vlingo-net/actors[Error]: vlingo-net/actors: FAILED: Actor proxy IGenericMethod not created for main or test: Actor proxy IGenericMethod not created because: Dynamically generated class source did not compile: Vlingo.Actors.Tests.GenericMethod__Proxy
vlingo-net/actors[Error] [Exception]: Actor proxy IGenericMethod not created for main or test: Actor proxy IGenericMethod not created because: Dynamically generated class source did not compile: Vlingo.Actors.Tests.GenericMethod__Proxy
vlingo-net/actors[Error] [StackTrace]:    at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, String targetClassName, String lookupTypeName) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 91
   at Vlingo.Actors.ActorProxy.CreateFor(Type protocol, Actor actor, IMailbox mailbox) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 45
   at Vlingo.Actors.ActorProxy.CreateFor[T](Actor actor, IMailbox mailbox) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 19
   at Vlingo.Actors.Stage.ActorProxyFor[T](Actor actor, IMailbox mailbox) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/Stage.cs:line 450
   at Vlingo.Actors.Stage.ActorProtocolFor[T](Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/Stage.cs:line 394
vlingo-net/actors[Error] [InnerException]: Actor proxy IGenericMethod not created because: Dynamically generated class source did not compile: Vlingo.Actors.Tests.GenericMethod__Proxy
vlingo-net/actors[Error] [InnerException-StackTrace]:    at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, ProxyGenerator generator, String targetClassName, String lookupTypeName) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 128
   at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, String targetClassName, String lookupTypeName) in /Users/tjaskula/Documents/GitHub/vlingo-net-actors/src/Vlingo.Actors/ActorProxy.cs:line 87

Error when running application with version 0.3.4

I was getting this error when installing the latest (0.3.4) version of Vlingo .net. I thought I might be doing something wrong, so I downloaded the demo app (Ping/Pong) and ran it and it worked fine. When I updated the NuGet to the latest (0.3.4) this error appeared when trying to run it, which is the same error I was getting when trying to run my code.

Stack trace:

Dynamically generated class source for Vlingo.Actors.Examples.PingPong.Pinger__Proxy did not compile because: The type or namespace name 'Common' does not exist in the namespace 'Vlingo' (are you missing an assembly reference?) at Vlingo.Common.Compiler.DynaCompiler.Compile(Input input) vlingo-net/actors: vlingo-net/actors: Generating proxy for test: IPinger Dynamically generated class source for Vlingo.Actors.Examples.PingPong.Pinger__Proxy did not compile because: The type or namespace name 'Common' does not exist in the namespace 'Vlingo' (are you missing an assembly reference?) at Vlingo.Common.Compiler.DynaCompiler.Compile(Input input) vlingo-net/actors: Actor instantiation failed because: Exception has been thrown by the target of an invocation. vlingo-net/actors [Exception]: Exception has been thrown by the target of an invocation. Actor instantiation failed because: Exception has been thrown by the target of an invocation. at Vlingo.Actors.Stage.CreateRawActor(Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger) at Vlingo.Actors.Stage.ActorProtocolFor[T](Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger) vlingo-net/actors [StackTrace]: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at Vlingo.Actors.ActorFactory.ActorFor(Stage stage, Actor parent, Definition definition, IAddress address, IMailbox mailbox, ISupervisor supervisor, ILogger logger) at Vlingo.Actors.Stage.CreateRawActor(Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger) vlingo-net/actors: vlingo-net/actors: FAILED: Actor instantiation failed because: Exception has been thrown by the target of an invocation. vlingo-net/actors [Exception]: Actor instantiation failed because: Exception has been thrown by the target of an invocation. vlingo-net/actors [StackTrace]: at Vlingo.Actors.Stage.CreateRawActor(Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger) at Vlingo.Actors.Stage.ActorProtocolFor[T](Definition definition, Actor parent, IAddress maybeAddress, IMailbox maybeMailbox, ISupervisor maybeSupervisor, ILogger logger)

Update async void usages

Push the async void usage down to the lowest possible component as a temporary implementation. Currently, async void usages are found in mailbox dispatcher plugins. Looking at the usages, they should be moved down to the Backoff implementation for now as a temporary state. Later, when we using Task fully everywhere, usages of async void should be removed and should only be allowed in top level consumer functions- which cannot return Tasks, but have to await on something.

Mailbox suspension while doing async/await

Today when doing async/await inside the actor the mailbox is not suspended, meaning the actor can be delivered new message while async method is being processed. This may be problematic:

  • rentrante breaks actor encapsulation
  • state of the actor may be corrupted if used by asynchronous operation while it's being changed by new message delivery

One option is to suspend mailbox while the asynchronous operation is ongoing. This has its own set of issues

  • mailbox contention, may be filled up quickly if asynchronous operation is taking time
  • probably performance

Proxy generator should check for reserved names

Sometimes if interface method signatures contain parameter names like @object, @event, and all the reserved .NET names, the generated proxy won't compile.

Before generating the parameter name, the check has to be done in the "reserved" keyword list and eventually change the name of the generated parameter.

Add additional check on constructor parameters type when creating an actor

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;
    }
}

Dynamic proxy generated class doesn't compile

I have this following error rising in vlingo-net-wire

System.ArgumentException: Actor proxy IResponseSenderChannel`1 not created for main or test: Actor proxy IResponseSenderChannel`1 not created because: Dynamically generated class source did not compile: Vlingo.Wire.Channel.ResponseSenderChannel__Proxy ---> System.ArgumentException: Actor proxy IResponseSenderChannel`1 not created because: Dynamically generated class source did not compile: Vlingo.Wire.Channel.ResponseSenderChannel__Proxy ---> System.ArgumentException: Dynamically generated class source did not compile: Vlingo.Wire.Channel.ResponseSenderChannel__Proxy
  at at Vlingo.Common.Compiler.DynaCompiler.Compile(Input input)
  at at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, ProxyGenerator generator, String targetClassName)
  --- End of inner exception stack trace ---
  at at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, ProxyGenerator generator, String targetClassName)
  at at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, String targetClassName)
  --- End of inner exception stack trace ---
  at at Vlingo.Actors.ActorProxy.TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, String targetClassName)
  at at Vlingo.Actors.ActorProxy.CreateFor(Type protocol, Actor actor, IMailbox mailbox)
  at at Vlingo.Actors.ActorProxy.CreateFor[T](Actor actor, IMailbox mailbox)
  at at Vlingo.Actors.Stage.ActorProxyFor[T](Actor actor, IMailbox mailbox)
  at at Vlingo.Actors.Actor.SelfAs[T]()
  at Vlingo.Wire.Channel.SocketChannelSelectionProcessorActor..ctor(IRequestChannelConsumerProvider provider, String name, Int32 maxBufferPoolSize, Int32 messageBufferSize, Int64 probeInterval) in /Users/tjaskula/Documents/GitHub/vlingo-net-wire/src/Vlingo.Wire/Channel/SocketChannelSelectionProcessorActor.cs:46

has to be investigated.

Add Travis integration

Related to #66

According to the following template

language: csharp
jobs:
  include:
    - os: linux
      dotnet: 3.0.100
      mono: none
    - os: osx
      osx_image: xcode11
      dotnet: 3.0.100
      mono: none
sudo: false  # use the new container-based Travis infrastructure
script:
  - dotnet restore ./src/Vlingo.UUID.sln;
    dotnet build ./src/Vlingo.UUID.sln;
    dotnet test ./src/Vlingo.UUID.Tests/Vlingo.UUID.Tests.csproj;

notifications:
  slack: vlingo-platform-net:kwiEEBuUpRnz2rYYYstTBpXr

Implement serialization mechanism as a plugin

Todays serialization is using Newtonsoft.Json but it would be better to move it to the existing plugin architecture.

Thus serialization could be parametrable and we could move to BinaryFormatter or another kind of serialization.

ConcurrentMailboxQueue overhelmed under aggressive load

Under some circumstances, especially when ISchedule is defined as actor protocol for network channel probing with an interval of 1ms and timeout of 1ms. The ensuing of task is faster than the task running. The actor queue may go up to several millions messages and the runing process slows down.

Load properties from App.config (or something similar)

Currently the Vlingo.Actors/Properties class loads properties/settings from a vlingo-actors.properties file. It needs to be modified to read from any standard configuration provider (such as App.config or Web.config). Please discuss your idea here before starting any implementation.

TestKit exception: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state.

I'm not sure if the real problem is in TestKit but this exception I had while testing in Vlingo.Wire. Needs to be investigated. @zpbappi if you have some suggestions I would be grateful here.

consoleLogger: Inbound stream listening: for 'mock'



                                                   Unhandled Exception:Unhandled Exception:Unhandled Exception:   
                                                                                                                  Unhandled Exception:
                                                                                                                                       Unhandled Exception: 
                                                                                                                                                            Unhandled Exception: 
                                                                                                                                                                                 Unhandled Exception: 

                                                                                                                                                                                                      Unhandled Exception:Unhandled Exception:  System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
                       at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
                                                                                                                                  at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
                                                                                                                                                                                                                at Vlingo.Actors.TestKit.TestWorld.Track(IMessage message)
                                          at Vlingo.Actors.Plugin.Mailbox.TestKit.TestMailbox.Send(IMessage message)
                                                                                                                       at Vlingo.Actors.Scheduled__Proxy.IntervalSignal(IScheduled scheduled, Object data)
                                                                                                                                                                                                             at Vlingo.Common.Scheduler.SchedulerTask.Tick(Object data)
                                       at System.Threading.TimerQueueTimer.<>c.<.cctor>b__22_0(Object state)
                                                                                                               at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       --- End of stack trace from previous location where exception was thrown ---
                                                                                      at System.Threading.ExeSystem.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
                                                                                                                       at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
                                                                                                                                                                                        at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
                     at Vlingo.Actors.TestKit.TestWorld.Track(IMessage message)
                                                                                  at Vlingo.Actors.Plugin.Mailbox.TestKit.TestMailbox.Send(IMessage message)
                                                                                                                                                               at Vlingo.Actors.Scheduled__Proxy.IntervalSignal(IScheduled scheduled, Object data)
                  at Vlingo.Common.Scheduler.SchedulerTask.Tick(Object data)
                                                                               at System.Threading.TimerQueueTimer.<>c.<.cctor>b__22_0(Object state)
                                                                                                                                                       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                               --- End of stack trace from previous location where exception was thrown ---
                                                                                                                              at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                         at System.Threading.TimerQueueTimer.CallCallback()
                                                                              at System.Threading.TimerQueueTimer.Fire()
                                                                                                                           at System.Threading.TimerQueue.FireNextTimers()
                                                                                                                                                                             at System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id)System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
                   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
                                                                                                                              at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
                                                                                                                                                                                                            at Vlingo.Actors.TestKit.TestWorld.Track(IMessage message)
                                      at Vlingo.Actors.Plugin.Mailbox.TestKit.TestMailbox.Send(IMessage message)
                                                                                                                   at Vlingo.Actors.Scheduled__Proxy.IntervalSignal(IScheduled scheduled, Object data)
                                                                                                                                                                                                         at Vlingo.Common.Scheduler.SchedulerTask.Tick(Object data)
                                   at System.Threading.TimerQueueTimer.<System.NullReferenceException: Object reference not set to an instance of an object.
                                                                                                                                                               at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
                                                                                                                                                                                                                                at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
                                                                at Vlingo.Actors.TestKit.TestWorld.Track(IMessage message)
                                                                                                                             at Vlingo.Actors.Plugin.Mailbox.TestKit.TestMailbox.Send(IMessage message)
                                                                                                                                                                                                          at Vlingo.Actors.Scheduled__Proxy.IntervalSignal(IScheduled scheduled, Object data)
                                                             at Vlingo.Common.Scheduler.SchedulerTask.Tick(Object data)
                                                                                                                          at System.Threading.TimerQueueTimer.<>c.<.cctor>b__22_0(Object state)
                                                                                                                                                                                                  at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                                                                          --- End of stack trace from previous location where exception was thrown ---
                                                                                                                                                                         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                                                    at System.Threading.TimerQueueTimer.CallCallback()
                                                                                                                         at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
                                                     at System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id)System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
                                                                                                                              at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
                                                                                                                                                                                               at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
                               at Vlingo.Actors.TestKit.TestWorld.Track(IMessage message)
                                                                                            at Vlingo.Actors.Plugin.Mailbox.TestKit.TestMailbox.Send(IMessage message)
                                                                                                                                                                         at Vlingo.Actors.Scheduled__Proxy.IntervalSignal(IScheduled scheduled, Object data)
                            at Vlingo.Common.Scheduler.SchedulerTask.Tick(Object data)
                                                                                         at System.Threading.TimerQueueTimer.<>c.<.cctor>b__22_0(Object state)
                                                                                                                                                                 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                                         --- End of stack trace from previous location where exception was thrown ---
                                                                                                                                        at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                   at System.Threading.TimerQueueTimer.CallCallback()
                                                                                        at System.Threading.TimerQueueTimer.Fire()
                                                                                                                                     at System.Threading.TimerQueueTimer.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
                                                                                                                                                                                                                                  at System.Threading.ThreadPoolWorkQueue.Dispatch()
                                                    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
                                                                                                                     System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
                                                                                                                               at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
       at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
                                                                                     at Vlingo.Actors.TestKit.TestWorld.Track(IMessage message)
                                                                                                                                                  at Vlingo.Actors.Plugin.Mailbox.TestKit.Te>c.<.cctor>b__22_0(Object state)
                                                                                                                                                                                                                               at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                                                                                                       --- End of stack trace from previous location where exception was thrown ---
                                                                                                                                                                                                      at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
                                                                                                 at System.Threading.TimerQueueTimer.CallCallback()
                                                                                                                                                      at System.Threading.TimerQueueTimer.Fire()
                                                                                                                                                                                                   at System.Threading.TimerQueue.FireNextTimers()
                  at System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id)
                                                                                 System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
                                                                                           at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
                                                                                                                                                            at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
                                                                                                                                                                                                                               at Vlingo.Actors.TestKit.TestWorld.Track(IMessage message)

Dynamic Proxy generator doesn't include all the using directives

Sometimes not enough using directives are added to the generated code so it doesn't compile. Here's one example:

using System;
using System.Collections.Generic;
using Vlingo.Actors;
using Vlingo.Common;
using Vlingo.Wire.Channel;
using System.Net.Sockets;

namespace Vlingo.Wire.Channel
{
    public class ResponseSenderChannel__Proxy : IResponseSenderChannel<Socket>
    {
        private const string AbandonRepresentation1 = "Abandon(RequestResponseContext<Socket>)";
        private const string RespondWithRepresentation2 = "RespondWith(RequestResponseContext<Socket>, IConsumerByteBuffer)";

        private readonly Actor actor;
        private readonly IMailbox mailbox;

        public ResponseSenderChannel__Proxy(Actor actor, IMailbox mailbox)
        {
            this.actor = actor;
            this.mailbox = mailbox;
        }

        public void Abandon(RequestResponseContext<Socket> context)
        {
            if(!actor.IsStopped)
            {
                Action<IResponseSenderChannel<Socket>> consumer = x => x.Abandon(context);
                if(mailbox.IsPreallocated)
                {
                    mailbox.Send(actor, consumer, null, AbandonRepresentation1);
                }
                else
                {
                    mailbox.Send(new LocalMessage<IResponseSenderChannel<Socket>>(actor, consumer, AbandonRepresentation1));
                }
            }
            else
            {
                actor.DeadLetters.FailedDelivery(new DeadLetter(actor, AbandonRepresentation1));
            }
        }
        public void RespondWith(RequestResponseContext<Socket> context, IConsumerByteBuffer buffer)
        {
            if(!actor.IsStopped)
            {
                Action<IResponseSenderChannel<Socket>> consumer = x => x.RespondWith(context, buffer);
                if(mailbox.IsPreallocated)
                {
                    mailbox.Send(actor, consumer, null, RespondWithRepresentation2);
                }
                else
                {
                    mailbox.Send(new LocalMessage<IResponseSenderChannel<Socket>>(actor, consumer, RespondWithRepresentation2));
                }
            }
            else
            {
                actor.DeadLetters.FailedDelivery(new DeadLetter(actor, RespondWithRepresentation2));
            }
        }

    }
}

It doesn't compile because IConsumerByteBuffer has no namespace using directive on the top of the file.

There are other examples as well, when I had System.Net.Sockets.Socket as proxy method parameter and using was not added

ProxyGenerator enhancements

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);

Generic constraints are wrongly generated in some cases

It seems that when a proxy is generated with a generic method, a constraint is generated even if not necessary.

An example is the following line

public void Write<TSource>(string id, TState state, int stateVersion, Vlingo.Symbio.Store.State.IWriteResultInterest interest) where TSource : 

The generic constraint where TSource : is unfinished.

The original interface method is

void Write<TSource>(string id, TState state, int stateVersion, IWriteResultInterest interest);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.