replace BinaryFormatter with System.Text.Json.JsonSerializer#960
replace BinaryFormatter with System.Text.Json.JsonSerializer#960yang-xiaodong merged 3 commits intodotnetcore:masterfrom ChangYinHan:master
Conversation
|
Hi brother, The BinaryFormatter has beed disabled by default at .NET 5, and an exception will be throw when running CAP with NATS at .NET 5. And this pull request will fix this bug. |
yang-xiaodong
left a comment
There was a problem hiding this comment.
Hello, Thanks for your PR, These are some problems that need improvement
| //return Task.FromResult(OperateResult.Success); | ||
|
|
||
| var reply = connection.Request(message.GetName(), mStream.ToArray(), 2000); | ||
| var json= JsonSerializer.Serialize(message); |
There was a problem hiding this comment.
We have the serialization interface, need to use ISerializer instead here
There was a problem hiding this comment.
Do you mean DotNetCore.CAP.Serialization.ISerializer?
There was a problem hiding this comment.
I have checked the DotNetCore.CAP.Serialization.ISerializer and JsonUtf8Serializer, they are based on Message not TransportMessage, may I add another method for TransportMessage?
There was a problem hiding this comment.
Consider using the version 0.14.0-pre1, which provides support for headers
https://github.com/nats-io/nats.net/releases/tag/0.14.0-pre1
There was a problem hiding this comment.
Thanks, I have updated to 0.14.0-pre1 now, and the interface ISerializer is no longer need, so I removed it.
|
|
||
| var message = (TransportMessage)binFormatter.Deserialize(mStream); | ||
| var json = UTF8Encoding.Default.GetString(e.Message.Data); | ||
| var message = JsonSerializer.Deserialize<TransportMessage>(json); |
There was a problem hiding this comment.
We have the serialization interface, need to use ISerializer instead here
| @@ -5,6 +5,8 @@ | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Runtime.Serialization.Formatters.Binary; | |||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\DotNetCore.CAP.InMemoryStorage\DotNetCore.CAP.InMemoryStorage.csproj" /> | ||
| <ProjectReference Include="..\..\src\DotNetCore.CAP.NATS\DotNetCore.CAP.NATS.csproj" /> |
There was a problem hiding this comment.
This is a unit test project, the integration test of NATS cannot be reference
| @@ -0,0 +1,57 @@ | |||
| using System; | |||
There was a problem hiding this comment.
There is no need to add integration tests for each Transport, so it can be removed
No description provided.