Add async MessagePack converter for method parameters#587
Conversation
Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Daniel-Svensson
left a comment
There was a problem hiding this comment.
@copilot please address review comments
| } | ||
|
|
||
| using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); | ||
| var envelope = (MessagePackResponseEnvelope)_serializer.DeserializeObject(stream, _typeShapeProvider.GetTypeShapeOrThrow(typeof(MessagePackResponseEnvelope))) |
There was a problem hiding this comment.
Create Request and Response types for Query, Invoke and Submit Operations.
For queries you can create a derived generic QueryCompletedResult
- Try to use PolyType attributes to annotate the Request and Response types
- If PolyType attributes is not enough (such as for request where parameters of type IDictionary<string,object>) is passed then consider custom Converters https://aarnott.github.io/Nerdbank.MessagePack/docs/custom-converters.html might be needed for serializing requests and deserializing responsees (in client project)
- Any converter must support async operation and follow security recommendations
In Hosting.AspNetCore the converters must deserialize requests and serialize responses.
In the server consider creating a FaultResponse class.
|
|
||
| internal sealed class MessagePackRequestEnvelope | ||
| { | ||
| public Dictionary<string, byte[]?>? Parameters { get; set; } = new(StringComparer.Ordinal); |
There was a problem hiding this comment.
change type to a new class "MethodParameters", and write a custom Converter for the type.
You should pass in DomainOperationEntry _operation to the MessagePackSerializers SerializationContext
Then the type should be serialized/deserialized as a map with keys set to parameter names ,
the actual data should be serialized by delegating to converter registered for the ParameterType of the corresponding "Parameters" on the DomainOperationEntry.
Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
Implemented the requested review updates in commit |
Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
* Parameter passing WORKS * DateTime passing don't throw (Need to investigate)
| var provider = ReflectionTypeShapeProvider.Default; | ||
| var responseType = typeof(MessagePackInvokeResponseEnvelope<>).MakeGenericType(resultType); | ||
| dynamic response = serializer.DeserializeObject(payload, provider.GetTypeShapeOrThrow(responseType)); | ||
| return (string)response.Result; |
| // If the name is new then should a separate property be added | ||
| // | ||
|
|
||
| string _name = (inner.AttributeProvider.GetCustomAttribute<IncludeAttribute>() is IncludeAttribute includeAttribute |
| catch (System.Exception) | ||
| { | ||
| // Ignore throwing domain services | ||
| continue; | ||
| } |
…ks working. 365 tests are now passing (with submit not yet working) , 323 failing



Review feedback called for
MethodParametersto use a custom Nerdbank.MessagePack converter that delegates each parameter to its declared type converter, carries operation metadata viaSerializationContext, and supports async serialization.Method parameter conversion
MethodParametersconverters on client and server.Async and security handling
DepthStep()and cancellation-aware async buffering/flush behavior.Wire schema and cleanup