Skip to content

Conversation

@JamieMagee
Copy link
Member

@JamieMagee JamieMagee commented Oct 30, 2025

This pull request contains the following changes:

  • Migration of some tests from Newtonsoft.Json.JsonConvert to System.Text.Json.JsonSerializer
  • Migration of PipInstallationReport from Newtonsoft.Json to System.Text.Json
    • No intermediate step was possible as it used JObject and JArray properties directly which cannot be handled by System.Text.Json
  • Made parameterless constructors in the TypedComponent hierarchy public instead of private or internal

Part of #231

@JamieMagee JamieMagee requested a review from a team as a code owner October 30, 2025 18:00
@JamieMagee JamieMagee requested a review from AMaini503 October 30, 2025 18:00
@github-actions
Copy link

github-actions bot commented Oct 30, 2025

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 222fb36 to ac777b6 Compare October 30, 2025 18:05
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 88.37209% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.2%. Comparing base (6d46b96) to head (54ba4b8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...tection.Contracts/TypedComponent/CondaComponent.cs 0.0% 1 Missing ⚠️
...ntracts/TypedComponent/DockerReferenceComponent.cs 0.0% 1 Missing ⚠️
...ection.Contracts/TypedComponent/DotNetComponent.cs 0.0% 1 Missing ⚠️
...etection.Contracts/TypedComponent/SpdxComponent.cs 0.0% 1 Missing ⚠️
...tection.Contracts/TypedComponent/VcpkgComponent.cs 0.0% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1523   +/-   ##
=====================================
  Coverage   90.2%   90.2%           
=====================================
  Files        426     426           
  Lines      35965   35965           
  Branches    2216    2216           
=====================================
+ Hits       32464   32465    +1     
  Misses      3045    3045           
+ Partials     456     455    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from ac777b6 to 633f0ab Compare November 14, 2025 04:57
Copilot AI review requested due to automatic review settings November 21, 2025 21:23
@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 633f0ab to 406cdf8 Compare November 21, 2025 21:23
Copilot finished reviewing on behalf of JamieMagee November 21, 2025 21:27
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 migrates test code from Newtonsoft.Json to System.Text.Json as part of issue #231. The migration maintains backward compatibility by adding dual serialization attributes to shared contract classes, allowing production code to continue using Newtonsoft.Json while tests use System.Text.Json.

Key Changes

  • Replaced JsonConvert.Serialize/Deserialize with JsonSerializer.Serialize/Deserialize in test files
  • Added System.Text.Json.Serialization attributes alongside existing Newtonsoft.Json attributes in pip contract classes
  • Fixed a comment in PyPiClientTests.cs to accurately reflect that an API call is made twice instead of once

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/Microsoft.ComponentDetection.VerificationTests/ComponentDetectionIntegrationTests.cs Updated serialization calls and imports for integration tests
test/Microsoft.ComponentDetection.Orchestrator.Tests/Services/DetectorProcessingServiceTests.cs Migrated telemetry deserialization to System.Text.Json
test/Microsoft.ComponentDetection.Detectors.Tests/YarnLockDetectorTests.cs Updated workspace JSON serialization in yarn lock tests
test/Microsoft.ComponentDetection.Detectors.Tests/SimplePypiClientTests.cs Migrated PyPI project serialization in simple client tests
test/Microsoft.ComponentDetection.Detectors.Tests/SimplePipComponentDetectorTests.cs Updated dependency graph serialization for error messages
test/Microsoft.ComponentDetection.Detectors.Tests/PyPiClientTests.cs Migrated PyPI client tests and fixed comment accuracy
test/Microsoft.ComponentDetection.Detectors.Tests/PipReportComponentDetectorTests.cs Updated pip report deserialization in detector tests
src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipInstallationReportItem.cs Added System.Text.Json attributes while maintaining Newtonsoft.Json compatibility
src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipInstallationReport.cs Added dual serialization attributes for transitional compatibility
src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipInstallationMetadata.cs Added System.Text.Json property name attributes alongside existing ones

@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 30146db to a009fc8 Compare November 21, 2025 22:38
Copilot AI review requested due to automatic review settings November 21, 2025 22:38
Copilot finished reviewing on behalf of JamieMagee November 21, 2025 22:43
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

Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.

Copilot AI review requested due to automatic review settings November 22, 2025 00:41
Copilot finished reviewing on behalf of JamieMagee November 22, 2025 00:45
@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 9978965 to b6e6d8a Compare November 22, 2025 00:46
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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from b6e6d8a to 3024c78 Compare November 22, 2025 00:50
Copilot AI review requested due to automatic review settings November 22, 2025 00:53
@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 3024c78 to 5f82a37 Compare November 22, 2025 00:53
@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 5f82a37 to 4bc88cc Compare November 22, 2025 00:56
Copilot finished reviewing on behalf of JamieMagee November 22, 2025 01:01
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

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 4bc88cc to b0daa3d Compare November 24, 2025 16:46
@JamieMagee JamieMagee requested a review from Copilot November 24, 2025 16:47
Copilot finished reviewing on behalf of JamieMagee November 24, 2025 16:50
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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@JamieMagee JamieMagee force-pushed the users/jamagee/system-text-json branch from 41b41e0 to 54ba4b8 Compare November 24, 2025 17:12
Copilot AI review requested due to automatic review settings November 24, 2025 17:12
Copilot finished reviewing on behalf of JamieMagee November 24, 2025 17:17
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

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.

@JamieMagee JamieMagee merged commit 9a2e5cd into main Nov 24, 2025
33 of 36 checks passed
@JamieMagee JamieMagee deleted the users/jamagee/system-text-json branch November 24, 2025 18:30
JamieMagee added a commit that referenced this pull request Nov 24, 2025
…ext.Json`

In #1523 we added the `[JsonProperty(Order = int.MinValue]` `Newtonsoft.Json` attribute to the `Type` property of the `TypedComponent` class to ensure that `"type"` would appear first in the serialized object. This is because `System.Text.Json` requires the type discriminator to be the first property of the object[^1]. `System.Text.Json` `9.0.0` and later does support the `JsonSerializerOptions.AllowOutOfOrder` option[^2], but as we're targeting .NET 8, we don't have access to that.

[^1]: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism#polymorphic-type-discriminators
[^2]: https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.allowoutofordermetadataproperties?view=net-10.0#system-text-json-jsonserializeroptions-allowoutofordermetadataproperties
JamieMagee added a commit that referenced this pull request Nov 24, 2025
…ext.Json` (#1558)

In #1523 we added the `[JsonProperty(Order = int.MinValue]` `Newtonsoft.Json` attribute to the `Type` property of the `TypedComponent` class to ensure that `"type"` would appear first in the serialized object. This is because `System.Text.Json` requires the type discriminator to be the first property of the object[^1]. `System.Text.Json` `9.0.0` and later does support the `JsonSerializerOptions.AllowOutOfOrder` option[^2], but as we're targeting .NET 8, we don't have access to that.

[^1]: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism#polymorphic-type-discriminators
[^2]: https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.allowoutofordermetadataproperties?view=net-10.0#system-text-json-jsonserializeroptions-allowoutofordermetadataproperties
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