Skip to content

Commit a940c1c

Browse files
committed
fix bugs with the current implementation
Signed-off-by: paule96 <[email protected]>
1 parent a31531a commit a940c1c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Dapr.Actors/Communication/ActorMessageBodyJsonSerializationProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public MemoryStreamMessageBodySerializer(
104104
{
105105
var _methodRequestParameterTypes = new List<Type>(methodRequestParameterTypes);
106106
var _wrappedRequestMessageTypes = new List<Type>(wrappedRequestMessageTypes);
107-
if(_wrappedRequestMessageTypes.Count != 1){
108-
throw new NotSupportedException("JSON serialisation should always provide the actor method, that was called" +
107+
if(_wrappedRequestMessageTypes.Count > 1){
108+
throw new NotSupportedException("JSON serialisation should always provide the actor method (or nothing), that was called" +
109109
" to support (de)serialisation. This is a dapr sdk error, open an issue on github.");
110110
}
111111
this.serializerOptions = new(serializerOptions)

src/Dapr.Actors/Communication/ActorMessageSerializersManager.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ internal CacheEntry CreateSerializers((int interfaceId, string methodName) data)
8787
else
8888
{
8989
// This path should be used for JSON serialization
90-
var requestWrapperTypeAsList = new List<Type>(1){
91-
interfaceDetails.RequestWrappedKnownTypes.Single(r => r.Name == $"{data.methodName}ReqBody")
92-
};
93-
var responseWrapperTypeAsList = new List<Type>(1){
94-
interfaceDetails.RequestWrappedKnownTypes.Single(r => r.Name == $"{data.methodName}RespBody")
95-
};
90+
var requestWrapperTypeAsList = interfaceDetails.RequestWrappedKnownTypes.Where(r => r.Name == $"{data.methodName}ReqBody").ToList();
91+
if(requestWrapperTypeAsList.Count > 1){
92+
throw new NotSupportedException($"More then one wrappertype was found for {data.methodName}");
93+
}
94+
var responseWrapperTypeAsList = interfaceDetails.ResponseWrappedKnownTypes.Where(r => r.Name == $"{data.methodName}RespBody").ToList();
95+
if(responseWrapperTypeAsList.Count > 1){
96+
throw new NotSupportedException($"More then one wrappertype was found for {data.methodName}");
97+
}
9698
return new CacheEntry(
9799
this.serializationProvider.CreateRequestMessageBodySerializer(serviceInterfaceType, requestBodyTypes, requestWrapperTypeAsList),
98100
this.serializationProvider.CreateResponseMessageBodySerializer(serviceInterfaceType, responseBodyTypes, responseWrapperTypeAsList));

0 commit comments

Comments
 (0)