Skip to content

Comments

Use System.Runtime.Serialization.Formatters NuGet package for .NET 8+ targets#15

Closed
Copilot wants to merge 3 commits intonoserfrom
copilot/replace-binaryformatter-nuget
Closed

Use System.Runtime.Serialization.Formatters NuGet package for .NET 8+ targets#15
Copilot wants to merge 3 commits intonoserfrom
copilot/replace-binaryformatter-nuget

Conversation

Copy link

Copilot AI commented Dec 29, 2025

BinaryFormatter is being removed in .NET 9. Microsoft provides System.Runtime.Serialization.Formatters as a NuGet package for .NET 8+ to maintain compatibility during the transition period.

Changes

Mbc.Pcs.Net.DataRecorder.csproj

  • Add conditional PackageReference to System.Runtime.Serialization.Formatters v10.0.1 for net8.0
  • Restrict EnableUnsafeBinaryFormatterSerialization to netstandard2.0 and net471 targets only

Mbc.Pcs.Net.DataRecorder.Test.csproj

  • Add conditional PackageReference to System.Runtime.Serialization.Formatters v10.0.1 for net8.0
  • Add EnableUnsafeBinaryFormatterSerialization for net8.0 to enable BinaryFormatter in tests

FileRingBufferTest.cs

  • Remove manual AppContext.SetSwitch call (no longer needed with NuGet package)

Behavior

Target Framework BinaryFormatter Source
netstandard2.0, net471 Built-in (legacy)
net8.0 NuGet package v10.0.1

The SerializationObjectPersister implementation remains unchanged - BinaryFormatter continues to work across all targets with appropriate configuration.

Original prompt

This section details on the original issue you should resolve

<issue_title>Replace BinaryFormatter with nuget Version </issue_title>
<issue_description>As in .net 9 BinaryFormatter() will be removed

https://steven-giesel.com/blogPost/4271d529-5625-4b67-bd59-d121f2d8c8f6/a-replacement-for-binaryformatter-in-net-8
</issue_description>

Comments on the Issue (you are @copilot in this section)

@bqstony We should use the new nuget 😎 for .net target beginning with version 8. The old framework targets can still use the current implementation

https://www.nuget.org/packages/System.Runtime.Serialization.Formatters/10.0.1#supportedframeworks-body-tab</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 29, 2025 07:56
…targets

Co-authored-by: bqstony <10487253+bqstony@users.noreply.github.com>
… project

Co-authored-by: bqstony <10487253+bqstony@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace BinaryFormatter with NuGet version Use System.Runtime.Serialization.Formatters NuGet package for .NET 8+ targets Dec 29, 2025
Copilot AI requested a review from bqstony December 29, 2025 08:02
@bqstony bqstony changed the base branch from master to noser January 4, 2026 17:13
@bqstony bqstony closed this Jan 4, 2026
@bqstony bqstony deleted the copilot/replace-binaryformatter-nuget branch January 4, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace BinaryFormatter with nuget Version

2 participants