Closed RemcoBlok closed 10 months ago
@RemcoBlok It looks like this is good, pending abiding by the DCO (sign-off) policy.
@RemcoBlok It looks like this is good, pending abiding by the DCO (sign-off) policy.
resolved the DCO issue.
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
d023a43
) 68.47% compared to head (27b8ad4
) 68.48%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@philliphoff It would appear the integration tests for .NET 7.0 fail occasionally. Last time they succeeded when trying again. I'm sure this occasional failure is not related to this PR. Could you try again please?
@philliphoff Thanks for approving the PR!
@RemcoBlok Thanks for the contribution!
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 aDerivedResponse
instance. Note that invokingInvokeMethodAsync<DerivedResponse>
is not polymorphic deserialization.While System.Text.Json support polymorphic deserialization from .NET 7, the Dapr .NET Actors SDK only builds .NET 6 and .NET 8, but not .NET 7. The E2E tests on the other hand do still build .NET 6, .NET 7 and .NET 8. As a consequence the .NET 7 build of the E2E tests uses the .NET 6 build of the .NET Actors SDK and does not run the polymorphic response test. Instead it runs a non-polymorphic test that directly deserializes to the derived class.
An operation on an actor invoked using a weakly-typed actor client should support a null response.
The problem was in the
ActorManager.DispatchWithoutRemotingAsync
method that serializes the response usingresult.GetType()
. This throws a null reference exception when the result is null. To support polymorphic deserialization in .NET 7 or later the serializer should use the declared return type on the interface instead of the runtime type.Closes #1213