dapr / dotnet-sdk

Dapr SDK for .NET
Apache License 2.0
1.12k stars 340 forks source link

Weakly-typed actors should support polymorphic response and null response #1213

Closed RemcoBlok closed 10 months ago

RemcoBlok commented 11 months ago

Expected Behavior

  1. In .NET 7.0 or later an operation on an actor invoked using a weakly-typed actor client should support a polymorphic response. The response json should include a type discriminator property to allow for polymorphic deserialization by the actor client. The weakly-typed actor client must polymorphically deserialize the response when invoking InvokeMethodAsync<ResponseBase> on the weakly-typed actor client. This should yield a DerivedResponse instance. Note that invoking InvokeMethodAsync<DerivedResponse> is not polymorphic deserialization.
  2. An operation on an actor invoked using a weakly-typed actor client should support a null response.

Actual Behavior

  1. The response json does not include a type discriminator. The deserialized response is an instance of the base response class, not the derived response class.
  2. A null reference exception is thrown by the ActorManager.DispatchWithoutRemotingAsync method.

Steps to Reproduce the Problem

  1. Declare an operation on an actor interface whose declared return type is a base class called ResponseBase. Implement the operation on an actor. The implementation returns an instance of a derived class called DerivedResponse. Invoke the operation using a weakly-typed actor client using the InvokeMethodAsync<ResponseBase> method (not using InvokeMethodAsync<DerivedResponse>).
  2. Return null from an actor operation invoked using a weakly-typed actor client.

Release Note

  1. RELEASE NOTE: Weakly-typed actor supports polymorphic response in .NET 7 or later.
  2. RELEASE NOTE: Weakly-typed actor supports null response.