-
Notifications
You must be signed in to change notification settings - Fork 575
Remove usage of Newtonsoft.Json in favor of System.Text.Json #1932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: twsouthwick <[email protected]>
…models Co-authored-by: twsouthwick <[email protected]>
Co-authored-by: twsouthwick <[email protected]>
Co-authored-by: twsouthwick <[email protected]>
|
@copilot - there are build errors. identify the issues and fix them |
Co-authored-by: twsouthwick <[email protected]>
…compatibility Co-authored-by: twsouthwick <[email protected]>
Build errors have been identified and fixed in commits 3a5700f and ff723c1. Issues found:
Fixes applied:
The build now succeeds with 0 errors and 0 warnings. |
Co-authored-by: twsouthwick <[email protected]>
Co-authored-by: twsouthwick <[email protected]>
…icle correctly Co-authored-by: twsouthwick <[email protected]>
Fixed the test failures in commit 117a12a. The
All tests now pass with 0 errors and 0 warnings. |
|
@copilot there should also be no references to Newtonsoft.Json in the code base after this change |
Co-authored-by: twsouthwick <[email protected]>
I've removed Newtonsoft.Json from test files and converted them to System.Text.Json. However, Newtonsoft.Json must remain in
Complete removal of Newtonsoft.Json would require either dropping support for older target frameworks or fundamentally changing how the source generator works. The test files now fully use System.Text.Json as requested. |
|
@copilot No - you don't seem to understand how th packages are structured. Remove all the newtonsoft packagereference and packageversion entries. it will be fine. |
Co-authored-by: twsouthwick <[email protected]>
Removed all Newtonsoft.Json PackageReference and PackageVersion entries in commit 4d5c446. The build succeeds with 0 errors and 0 warnings, and all tests pass. The entire codebase now uses System.Text.Json exclusively. |
Summary
This PR completely removes Newtonsoft.Json from the codebase and migrates all code to System.Text.Json.
Changes Made
Test file migration: Converted test files to use System.Text.Json with custom converters:
TypeNameConverter- serializes Type objects by their full nameQNameConverter- serializes OpenXmlQualifiedName objectsParticleConstraintConverter- replicates the behavior of the originalOccursDefaultResolverfrom Newtonsoft.Json using reflection to discover all properties and then applying exceptions:Version,RequireFilter, and internal/computed propertiesParticleConstraintand its subclasses (CompositeParticle,ElementParticle,AnyParticle)Generator models migration: Converted generator models to use System.Text.Json:
QualifiedNameConverter- converts QName objects for System.Text.JsonTypedQNameConverter- converts TypedQName objects for System.Text.JsonOpenXmlGeneratorDataSourceto use System.Text.JsonComplete Newtonsoft.Json removal:
PackageReferenceentries for Newtonsoft.JsonPackageVersionentry for Newtonsoft.Json from Directory.Packages.propsStyleCop warnings: Fixed trailing comma and whitespace issues in test files.
Reverted unnecessary changes: Restored LangVersion to 13, SDK version to 9.0.100, and System.Collections.Immutable to 9.0.4.
Native indentation: Replaced string replacement hacks with
Utf8JsonWriterusingIndentSize = 1for proper JSON formatting.Clean code: Removed conversion-related comments that reference the old implementation.
The codebase now builds successfully with 0 errors and 0 warnings. All tests pass. The entire codebase now uses System.Text.Json exclusively with no remaining references to Newtonsoft.Json.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.