Skip to content

Commit fb245a5

Browse files
authored
fix(NewtonsoftJson)!: Upgrade RecyclableMemoryStream (#118)
1 parent f018f62 commit fb245a5

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ The `Unreleased` section name is replaced by the expected version of next releas
1010

1111
### Added
1212

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

1715
### Changed
1816
### Removed
1917
### Fixed
2018

19+
- `NewtonsoftJson`: Upped `RecyclableMemoryStream` to [`>= 3.0.0` to handle breaking change in `GetStream` return type](
20+
https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream/releases/tag/3.0.0) [#118](https://github.com/jet/FsCodec/pull/118)
21+
2122
<a name="3.0.0-rc.16"></a>
2223
## [3.0.0-rc.16] - 2024-1-27
2324

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The components within this repository are delivered as multi-targeted Nuget pack
2020
- [![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)
2121
- Uses the ubiquitous [`Newtonsoft.Json`](https://github.com/JamesNK/Newtonsoft.Json) library to serialize the event bodies.
2222
- Provides relevant Converters for common non-primitive types prevalent in F#
23-
- [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`
23+
- [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`
2424
- [![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.
2525
- [depends](https://www.fuget.org/packages/FsCodec.SystemTextJson) on `FsCodec.Box`, `System.Text.Json >= 6.0.1`,
2626

src/FsCodec.NewtonsoftJson/FsCodec.NewtonsoftJson.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

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

23-
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" />
23+
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
2424
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2525
<PackageReference Include="System.Buffers" Version="4.5.1" />
2626
</ItemGroup>

src/FsCodec.NewtonsoftJson/Serdes.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module private CharBuffersPool =
1616
// http://www.philosophicalgeek.com/2015/02/06/announcing-microsoft-io-recycablememorystream/
1717
module private Utf8BytesEncoder =
1818
let private streamManager = Microsoft.IO.RecyclableMemoryStreamManager()
19-
let rentStream () = streamManager.GetStream("bytesEncoder")
19+
// NOTE GetStream return type changes from MemoryStream to RecyclableMemoryStream in V2-V3
20+
let rentStream (): MemoryStream = streamManager.GetStream("bytesEncoder")
2021
let wrapAsStream (utf8json: ReadOnlyMemory<byte>) =
2122
// This is the most efficient way of approaching this without using Spans etc.
2223
// RecyclableMemoryStreamManager does not have any wins to provide us

0 commit comments

Comments
 (0)