Repository navigation
Conversation
Add MemoryPack.Tests.NetStandard, which links the sources of MemoryPack.Tests and references MemoryPack.Core and MemoryPack.Streaming with SetTargetFramework=netstandard2.1. NET*_OR_GREATER symbols are disabled so that test code and generated code take the same path as netstandard2.1 consumers (e.g. Unity). - Exclude source generator tests and MemoryLayoutTest, which do not depend on the target framework of the libraries. - Skip SerializerStructBufferWriterTest when NET7_0_OR_GREATER is not defined, because the netstandard2.1 build requires TBufferWriter to be a reference type. - Register external union formatters manually in UnionTest when NET5_0_OR_GREATER is not defined, because generated initializers have [ModuleInitializer] only in that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Microsoft.NET.Test.Sdk 17.3.1 is distributed under the Microsoft .NET Library license (LICENSE_NET.txt), which is not in the allow list of dependency-review. 17.10.0 and later use the MIT license expression. Update both test projects to the same version, because they share the same test sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Drop net7.0 from the libraries and add net10.0. MemoryPack.Streaming also gets net8.0, so that .NET 8 apps keep using the net* builds of both MemoryPack.Core and MemoryPack.Streaming. - MemoryPack.AspNetCoreMvcFormatter: net6.0;net7.0 -> net8.0;net10.0. - The source generator switches the generated code by NET8_0_OR_GREATER instead of NET7_0_OR_GREATER, because apps on .NET 7 or lower now resolve to the netstandard2.1 build. MEMPACK034 keeps NET7_0_OR_GREATER, as it is about the struct layout of the runtime. - Reference System.IO.Pipelines only below net9.0. It is part of the shared framework in .NET 9 or later. - Run the tests on net8.0 and net10.0, and the netstandard2.1 tests on net10.0. - SandboxWebApp: net7.0 -> net10.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Now that net7.0 is dropped, NET5_0_OR_GREATER, NET7_0_OR_GREATER and NET8_0_OR_GREATER all mean "not the netstandard2.1 build" in MemoryPack.Core. The behavior of each build is not changed. The code generated by the source generator and the test code keep the original symbols, because they are compiled with the symbols of the consuming project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They target net6.0 and net7.0, which are out of support. Net6VsNet7 compared the .NET 6 and .NET 7 runtimes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Recommend .NET 10 instead of .NET 7. - Target framework dependency: library authors should multi-target netstandard2.1 and net8.0 instead of net7.0. - Remove the note about the .NET 7 Native AOT crash, which was fixed in .NET 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Cross-framework test parallelism can cause concurrent access to the shared temporary FullName.ts file, leading to sharing errors, incomplete reads, and intermittent test failures.
1 open issue
What changed in this PR
Modernizes MemoryPack’s framework targets and aligns generated serializers with the selected library build. It also incorporates #468’s test coverage for the .NET Standard implementation.
Changes:
- Replace .NET 6/7 package targets with .NET 8/10, retaining .NET Standard 2.1 where supported.
- Simplify Core’s conditional compilation and select modern generator output starting with .NET 8.
- Expand test targets, remove legacy sandboxes, and refresh compatibility guidance.
| File | Description |
|---|---|
| tests/MemoryPack.Tests/Utils/CSharpGeneratorRunner.cs | Add the default .NET 8 generator symbol. |
| tests/MemoryPack.Tests/UnionTest.cs | Register union formatters when module initializers are unavailable. |
| tests/MemoryPack.Tests/SerializerStructBufferWriterTest.cs | Exclude unsupported struct-writer tests from standard-build coverage. |
| tests/MemoryPack.Tests/MemoryPack.Tests.csproj | Test .NET 8/10 and update the test SDK. |
| tests/MemoryPack.Tests.NetStandard/MemoryPack.Tests.NetStandard.csproj | Run shared tests against standard assets on .NET 10. |
| src/MemoryPack/MemoryPack.csproj | Update meta-package framework targets. |
| src/MemoryPack.UnityShims/MemoryPack.UnityShims.csproj | Update Unity shims framework targets. |
| src/MemoryPack.Streaming/MemoryPack.Streaming.csproj | Update targets and condition the Pipelines dependency. |
| src/MemoryPack.Generator/MemoryPackGenerator.Emitter.cs | Gate modern generated code on .NET 8. |
| src/MemoryPack.Generator/MemoryPackGenerator.cs | Track consuming projects’ .NET 8 symbols. |
| src/MemoryPack.Generator/IGeneratorContext.cs | Separate asset-selection and runtime-layout flags. |
| src/MemoryPack.Core/MemoryPackWriterOptionalState.cs | Simplify reference-tracking compilation guards. |
| src/MemoryPack.Core/MemoryPackWriter.cs | Simplify writer implementation and constraint guards. |
| src/MemoryPack.Core/MemoryPackSerializerOptions.cs | Restrict compatibility support to standard builds. |
| src/MemoryPack.Core/MemoryPackSerializer.Serialize.cs | Simplify serialization fast-path and constraint guards. |
| src/MemoryPack.Core/MemoryPackSerializer.NonGenerics.cs | Simplify non-generic serialization constraint guards. |
| src/MemoryPack.Core/MemoryPackSerializer.Deserialize.cs | Simplify trimming-annotation guards. |
| src/MemoryPack.Core/MemoryPackReader.cs | Simplify reader implementation guards. |
| src/MemoryPack.Core/MemoryPackFormatterProvider.WellknownTypes.tt | Update formatter-registration template guards. |
| src/MemoryPack.Core/MemoryPackFormatterProvider.WellknownTypes.cs | Update generated formatter-registration guards. |
| src/MemoryPack.Core/MemoryPackFormatterProvider.cs | Simplify formatter registration and discovery guards. |
| src/MemoryPack.Core/MemoryPack.Core.csproj | Target .NET Standard 2.1 and .NET 8/10. |
| src/MemoryPack.Core/Internal/TypeHelpers.cs | Simplify fixed-size packable detection guards. |
| src/MemoryPack.Core/Internal/ReusableReadOnlySequenceBuilder.cs | Simplify span-based iteration guards. |
| src/MemoryPack.Core/Internal/ReusableLinkedArrayBufferWriter.cs | Simplify buffer optimizations and constraint guards. |
| src/MemoryPack.Core/Internal/MemoryMarshalEx.cs | Limit compatibility helpers to standard builds. |
| src/MemoryPack.Core/Internal/EnumerableExtensions.cs | Simplify collection-count optimization guards. |
| src/MemoryPack.Core/IMemoryPackFormatter.cs | Simplify formatter buffer-writer constraint guards. |
| src/MemoryPack.Core/IMemoryPackable.cs | Simplify static-abstract interface guards. |
| src/MemoryPack.Core/Formatters/TypeFormatter.cs | Simplify generated-regex guards. |
| src/MemoryPack.Core/Formatters/StringBuilderFormatter.cs | Simplify optimized string-builder serialization guards. |
| src/MemoryPack.Core/Formatters/MultiDimensionalArrayFormatters.cs | Simplify unmanaged-array fast-path guards. |
| src/MemoryPack.Core/Formatters/MemoryPackableFormatter.cs | Limit the modern formatter to nonstandard builds. |
| src/MemoryPack.Core/Formatters/KeyValuePairFormatter.cs | Simplify buffer-writer constraint guards. |
| src/MemoryPack.Core/Formatters/InterfaceCollectionFormatters.cs | Simplify collection support and optimization guards. |
| src/MemoryPack.Core/Formatters/ImmutableCollectionFormatters.cs | Simplify immutable-array deserialization guards. |
| src/MemoryPack.Core/Formatters/FrozenCollectionFormatter.cs | Enable frozen collections in nonstandard builds. |
| src/MemoryPack.Core/Formatters/CollectionFormatters.cs | Simplify collection fast-path and availability guards. |
| src/MemoryPack.Core/Compression/BrotliCompressor.cs | Simplify compressor implementation and API guards. |
| src/MemoryPack.Core/Compression/BitPackFormatter.cs | Simplify vectorized bit-packing guards. |
| src/MemoryPack.AspNetCoreMvcFormatter/MemoryPack.AspNetCoreMvcFormatter.csproj | Target ASP.NET Core 8/10. |
| sandbox/SandboxWebApp/SandboxWebApp.csproj | Move the web sandbox to .NET 10. |
| sandbox/SandboxNet6/SandboxNet6.csproj | Remove the .NET 6 sandbox project. |
| sandbox/SandboxNet6/Program.cs | Remove legacy sandbox examples. |
| sandbox/SandboxNet6/NamespaceTest.cs | Remove the legacy namespace example. |
| sandbox/Net6VsNet7/Program.cs | Remove .NET 6/7 comparison benchmarks. |
| sandbox/Net6VsNet7/Net6VsNet7.csproj | Remove the legacy benchmark project. |
| README.md | Update framework guidance and remove the obsolete AOT warning. |
| MemoryPack.sln | Add standard-build tests and remove legacy sandboxes. |
Review effort: Balanced
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <TargetFrameworks>net8.0;net10.0</TargetFrameworks> |
The tests of each target framework run in parallel with the .NET 9 SDK or later, and the TypeScript generator tests wrote the same files (such as FullName.ts and MemoryPackWriter.ts) into the temp directory. Each TypeScriptOptionProvider now creates its own directory with Directory.CreateTempSubdirectory and deletes it when disposed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Note
This PR is based on #468 and includes its two commits. Please merge #468 first. The changes of this PR are the last four commits.
Summary
.NET 6 and .NET 7 are out of support, and .NET 10 is the current LTS. This PR drops
net6.0andnet7.0, addsnet10.0, and keepsnet8.0.net7.0;net8.0;netstandard2.1netstandard2.1;net8.0;net10.0net7.0;netstandard2.1netstandard2.1;net8.0;net10.0net6.0;net7.0net8.0;net10.0MemoryPack.Streaming gets
net8.0so that .NET 8 apps keep using thenet*builds of both MemoryPack.Core and MemoryPack.Streaming.Dependency versions are not changed in this PR.
Changes
netstandard2.1build, so the check is changed fromNET7_0_OR_GREATERtoNET8_0_OR_GREATER.#if: In MemoryPack.Core,NET5_0_OR_GREATER,NET7_0_OR_GREATERandNET8_0_OR_GREATERall mean "not thenetstandard2.1build" now, so they are replaced withNETSTANDARD(107 places, including the.tttemplate). The code generated by the source generator ([ModuleInitializer]under#if NET5_0_OR_GREATER) and the test code keep the original symbols, because they are compiled with the symbols of the consuming project.System.IO.Pipelinesis referenced only belownet9.0. It is part of the shared framework in .NET 9 or later.net8.0andnet10.0, and MemoryPack.Tests.NetStandard runs onnet10.0. The default preprocessor symbols ofCSharpGeneratorRunnerincludeNET8_0_OR_GREATER.Net6VsNet7andSandboxNet6are removed.SandboxWebApptargetsnet10.0.netstandard2.1;net8.0), and removes the note about the .NET 7 Native AOT crash.Impact on consumers
Apps on .NET 7 resolve to the
netstandard2.1build of MemoryPack. With the generator change above, most of them keep working, but they break if they:net*builds, such as a structIBufferWriter<byte>(build error);net7.0asset built against MemoryPack, as the README recommended (MissingMethodExceptionat run time); orIReadOnlySet<T>orPriorityQueue<TElement, TPriority>(MemoryPackSerializationExceptionat run time).They also lose some fast paths of the
net*builds. For example, deserializingList<T>adds the elements one by one instead of usingCollectionsMarshal.SetCount, andImmutableArray<T>is created from a copy.MemoryPack.AspNetCoreMvcFormatter no longer supports .NET 6 and .NET 7.
These apps need to move to .NET 8 or later, or stay on 1.22.x. When they move to .NET 10, note that
DateTimeOffsetserialized on .NET 9 or lower can not be deserialized correctly asDateTimeOffset(seeNet10DateTimeOffsetand MEMPACK043).The wire format is not changed. Apps on .NET 8 or later, apps on .NET 6 or lower (except MemoryPack.AspNetCoreMvcFormatter users), and Unity are not affected.
🤖 Generated with Claude Code