ServiceBus.Formatters
1.4.2
dotnet add package ServiceBus.Formatters --version 1.4.2
NuGet\Install-Package ServiceBus.Formatters -Version 1.4.2
<PackageReference Include="ServiceBus.Formatters" Version="1.4.2" />
<PackageVersion Include="ServiceBus.Formatters" Version="1.4.2" />
<PackageReference Include="ServiceBus.Formatters" />
paket add ServiceBus.Formatters --version 1.4.2
#r "nuget: ServiceBus.Formatters, 1.4.2"
#:package ServiceBus.Formatters@1.4.2
#addin nuget:?package=ServiceBus.Formatters&version=1.4.2
#tool nuget:?package=ServiceBus.Formatters&version=1.4.2
ServiceBus.Formatters
The serialization contract used by ServiceBus.Core: how a message becomes the bytes sent through the broker and back. Two packages implement it, ServiceBus.Formatters.Ms (System.Text.Json) and ServiceBus.Formatters.Newtonsoft (Newtonsoft.Json), and they are interchangeable behind it. You normally install one of them, which brings this package with it.
The contract
IDataFormatter joins an encoder and a decoder:
| Member | What it does |
|---|---|
Encode(object) |
writes a value as bytes |
Decode<TData>(byte[]), Decode<TData>(ReadOnlyMemory<byte>) |
reads a value of a known type |
Decode(byte[], Type), Decode(ReadOnlyMemory<byte>, Type) |
reads a value of a type known only at run time |
Encoder |
the Encoding of the text |
IJsonSerializer does the same for JSON text instead of bytes.
What every implementation does
| Case | Result |
|---|---|
| Payload that starts with a byte order mark | read normally; the mark is never written |
| Empty payload (no bytes, only the mark, or only JSON white space) | "no value": null for a reference type or a Nullable<T>, an exception for any other value type |
null array |
ArgumentNullException (a mistake of the caller, not an empty message) |
A subscriber therefore receives Data = null for an empty message, whichever formatter is used.
Choosing one
ServiceBus.Formatters.Ms |
ServiceBus.Formatters.Newtonsoft |
|
|---|---|---|
| Serializer | System.Text.Json |
Newtonsoft.Json |
| Encoding | UTF-8 only | any Encoding |
| Speed and memory | faster, allocates less | slower, allocates more |
In the benchmark of the repository (tools/FormatterBenchmark, messages from 196 bytes to 93 KB) System.Text.Json decodes about 1.4 to 1.7 times and encodes about 1.8 to 1.9 times faster than the Newtonsoft formatters, and allocates 20 to 27% less decoding and about 60% less encoding.
Targets: net8.0, net9.0, net10.0. netstandard2.1 and net6.0 are no longer targets: applications on them stay on the earlier releases. See the documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ServiceBus.Formatters:
| Package | Downloads |
|---|---|
|
ServiceBus.Core.Rabbit
This is a custom library which implements ServiceBus.Core contracts, using RabbitMq as underlying service bus layer. |
|
|
ServiceBus.Formatters.Ms
This is an easy library which exposes some contracts used to serialize and deserialize messages incoming from ESB brokers, based in microsoft serializer. |
|
|
ServiceBus.Formatters.Newtonsoft
This is easy library which exposes some contracts used to serialize and deserialize messages incoming from ESB brokers, based in newtownsoft serializer. |
GitHub repositories
This package is not used by any popular GitHub repositories.