Skip to content

Commit

Permalink
fix(NewtonsoftJson)!: Up RecyclableMemoryStream to handle breaking ch…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
bartelink committed Feb 26, 2024
1 parent f018f62 commit 1dede23
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ The `Unreleased` section name is replaced by the expected version of next releas

### Added

### Added

- `TypeSafeEnum.caseValues<'t>`: Yields all values of a union (that is a `TypeSafeEnum`) [#115](https://github.com/jet/FsCodec/pull/115)

### Changed
### Removed
### Fixed

- `NewtonsoftJson`: Upped `RecyclableMemoryStream` to [`>= 3.0.0` to handle breaking change in `GetStream` return type](
https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream/releases/tag/3.0.0) [#118](https://github.com/jet/FsCodec/pull/118)

<a name="3.0.0-rc.16"></a>
## [3.0.0-rc.16] - 2024-1-27

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The components within this repository are delivered as multi-targeted Nuget pack
- [![Newtonsoft.Json Codec NuGet](https://img.shields.io/nuget/v/FsCodec.NewtonsoftJson.svg)](https://www.nuget.org/packages/FsCodec.NewtonsoftJson/) `FsCodec.NewtonsoftJson`: As described in [a scheme for the serializing Events modelled as an F# Discriminated Union](https://eiriktsarpalis.wordpress.com/2018/10/30/a-contract-pattern-for-schemaless-datastores/), enabled tagging of F# Discriminated Union cases in a versionable manner with low-dependencies using [TypeShape](https://github.com/eiriktsarpalis/TypeShape)'s [`UnionContractEncoder`](https://eiriktsarpalis.wordpress.com/2018/10/30/a-contract-pattern-for-schemaless-datastores)
- Uses the ubiquitous [`Newtonsoft.Json`](https://github.com/JamesNK/Newtonsoft.Json) library to serialize the event bodies.
- Provides relevant Converters for common non-primitive types prevalent in F#
- [depends](https://www.fuget.org/packages/FsCodec.NewtonsoftJson) on `FsCodec.Box`, `Newtonsoft.Json >= 13.0.3`, `Microsoft.IO.RecyclableMemoryStream >= 2.2.0`, `System.Buffers >= 4.5.1`
- [depends](https://www.fuget.org/packages/FsCodec.NewtonsoftJson) on `FsCodec.Box`, `Newtonsoft.Json >= 13.0.3`, `Microsoft.IO.RecyclableMemoryStream >= 3.0.0`, `System.Buffers >= 4.5.1`
- [![System.Text.Json Codec NuGet](https://img.shields.io/nuget/v/FsCodec.SystemTextJson.svg)](https://www.nuget.org/packages/FsCodec.SystemTextJson/) `FsCodec.SystemTextJson`: See [#38](https://github.com/jet/FsCodec/pulls/38): drop in replacement that allows one to retarget from `Newtonsoft.Json` to the .NET Core >= v 3.0 default serializer: `System.Text.Json`, solely by changing the referenced namespace.
- [depends](https://www.fuget.org/packages/FsCodec.SystemTextJson) on `FsCodec.Box`, `System.Text.Json >= 6.0.1`,

Expand Down
2 changes: 1 addition & 1 deletion src/FsCodec.NewtonsoftJson/FsCodec.NewtonsoftJson.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<PackageReference Include="FSharp.Core" Version="4.5.4" />

<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/FsCodec.NewtonsoftJson/Serdes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module private CharBuffersPool =
// http://www.philosophicalgeek.com/2015/02/06/announcing-microsoft-io-recycablememorystream/
module private Utf8BytesEncoder =
let private streamManager = Microsoft.IO.RecyclableMemoryStreamManager()
let rentStream () = streamManager.GetStream("bytesEncoder")
// NOTE GetStream return type changes from MemoryStream to RecyclableMemoryStream in V2-V3
let rentStream (): MemoryStream = streamManager.GetStream("bytesEncoder")
let wrapAsStream (utf8json: ReadOnlyMemory<byte>) =
// This is the most efficient way of approaching this without using Spans etc.
// RecyclableMemoryStreamManager does not have any wins to provide us
Expand Down

0 comments on commit 1dede23

Please sign in to comment.