-
Notifications
You must be signed in to change notification settings - Fork 113
Add System.Text.Json attributes
#1556
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
base: main
Are you sure you want to change the base?
Conversation
Prepare codebase for migration to System.Text.Json by adding `JsonPropertyName` attributes to all serializable models while maintaining `Newtonsoft.Json` compatibility. Changes: - Add `JsonPropertyName` attributes to serializable model properties - Add `JsonIgnore(Condition.WhenWritingNull)` to optional properties - Explicitly specify `[JsonConverter(typeof(JsonStringEnumConverter))]` for serializable enums All serialization tests pass. Both `Newtonsoft.Json` and `System.Text.Json` attributes now coexist, enabling gradual migration.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1556 +/- ##
=====================================
Coverage 90.2% 90.2%
=====================================
Files 426 426
Lines 35965 35965
Branches 2216 2216
=====================================
+ Hits 32463 32465 +2
Misses 3045 3045
+ Partials 457 455 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 prepares the codebase for migration from Newtonsoft.Json to System.Text.Json by adding JsonPropertyName and JsonConverter attributes alongside existing Newtonsoft.Json attributes. The changes span serializable models across detector contracts, typed components, and BCDE models, maintaining backward compatibility during the transition.
Key changes:
- Added
System.Text.Json.Serialization.JsonPropertyNameattributes to all serializable properties - Added
System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))to enums - Added
JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)to nullable properties alongside Newtonsoft.Json'sNullValueHandling.Ignore
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vcpkg/Contracts/ManifestInfo.cs | Added JsonPropertyName for manifest-path property |
| swiftpm/Contracts/SwiftResolvedFile.cs | Added JsonPropertyName to all Swift package resolution properties |
| pip/Contracts/*.cs | Added JsonPropertyName to Python package metadata properties |
| TypedComponent/*.cs | Added JsonPropertyName to component type properties across all ecosystems |
| BcdeModels/*.cs | Added JsonPropertyName to scan result and container detail properties with camelCase naming |
| ComponentType.cs, ProcessingResultCode.cs, DependencyScope.cs | Added JsonConverter(typeof(JsonStringEnumConverter)) for enum serialization |
src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonProjectRelease.cs
Outdated
Show resolved
Hide resolved
|
👋 Hi! It looks like you modified some files in the
If none of the above scenarios apply, feel free to ignore this comment 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 39 out of 39 changed files in this pull request and generated no new comments.
Prepare codebase for migration to
System.Text.Jsonby addingJsonPropertyNameattributes to all serializable models while maintainingNewtonsoft.Jsoncompatibility.Changes:
JsonPropertyNameattributes to serializable model propertiesJsonIgnore(Condition.WhenWritingNull)to optional properties[JsonConverter(typeof(JsonStringEnumConverter))]for serializable enumsAll serialization tests pass. Both
Newtonsoft.JsonandSystem.Text.Jsonattributes now coexist, enabling gradual migration.