Skip to content

在 net8.0 和 net9.0 中,完全移除 Newtonsoft.Json,使用 System.Text.Json#166

Merged
lindexi merged 22 commits intomainfrom
t/lvyi/system-text-json
Sep 3, 2025
Merged

在 net8.0 和 net9.0 中,完全移除 Newtonsoft.Json,使用 System.Text.Json#166
lindexi merged 22 commits intomainfrom
t/lvyi/system-text-json

Conversation

@walterlv
Copy link
Member

@walterlv walterlv commented Sep 3, 2025

重大变更

  • 本次修改在 net8.0 和 net9.0 框架中完全移除了 Newtonsoft.Json
  • 不再支持本机类型(nint/IntPtr) 的 IPC 传输

本次更改

  1. 在 net8.0 和 net9.0 中,完全移除 Newtonsoft.Json,使用 System.Text.Json
  2. 仍然支持且兼容旧框架
    • 使各框架都正常工作,既可在 Newtonsoft.Json 下正常工作,又可在 System.Text.Json 下正常工作
    • IPC 传输二进制兼容,即升级库后的程序,能够与以前老库程序仍然正常进行 IPC 通信
    • IpcObjectJsonSerializer 类型在 net8.0 和 net9.0 中标记为删除且不再可用外,其他二进制和源码都兼容

其他说明

单元测试全部通过,这包括了 Newtonsoft.Json 和 System.Text.Json 两个不同 JSON 底层的所有测试,甚至还包括了二者之间互传的兼容。

image

NuGet 的依赖已更新为如下:

image

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes Newtonsoft.Json dependency from net8.0 and net9.0 frameworks and transitions to System.Text.Json for IPC object serialization. The change maintains backward compatibility with older frameworks and ensures binary compatibility for IPC communication between applications using different JSON serialization backends.

Key changes:

  • Complete removal of Newtonsoft.Json in net8.0+ frameworks, replaced with System.Text.Json
  • Maintained support for Newtonsoft.Json in legacy frameworks (net6.0 and below)
  • Added framework-specific test configurations to validate both serialization mechanisms

Reviewed Changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.

File Description
src/dotnetCampus.Ipc/dotnetCampus.Ipc.csproj Updated target frameworks and conditional compilation for JSON serializers
src/dotnetCampus.Ipc/Serialization/ Complete rewrite of serialization layer with System.Text.Json support
tests/dotnetCampus.Ipc.Tests/ Added multi-framework testing and framework-specific JSON context
src/dotnetCampus.Ipc/CompilerServices/GeneratedProxies/ Updated proxy generation to work with both JSON serializers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lindexi lindexi assigned walterlv and unassigned lindexi Sep 3, 2025
@lindexi lindexi merged commit 6d087eb into main Sep 3, 2025
2 of 4 checks passed
@lindexi lindexi deleted the t/lvyi/system-text-json branch September 3, 2025 12:30
lindexi added a commit to dotnet-campus/DocumentFormat.OpenXml.Extensions that referenced this pull request Sep 5, 2025
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.

3 participants