Skip to content

Conversation

@JamieMagee
Copy link
Member

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 object1. System.Text.Json 9.0.0 and later does support the JsonSerializerOptions.AllowOutOfOrder option2, but as we're targeting .NET 8, we don't have access to that.

Footnotes

  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

…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
Copilot AI review requested due to automatic review settings November 24, 2025 19:23
@JamieMagee JamieMagee requested a review from a team as a code owner November 24, 2025 19:23
Copilot finished reviewing on behalf of JamieMagee November 24, 2025 19:25
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.2%. Comparing base (9a2e5cd) to head (49dd80d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1558   +/-   ##
=====================================
  Coverage   90.2%   90.2%           
=====================================
  Files        426     426           
  Lines      35965   35965           
  Branches    2216    2216           
=====================================
+ Hits       32463   32464    +1     
  Misses      3045    3045           
+ Partials     457     456    -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.

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 the ComponentDetectionIntegrationTests class from Newtonsoft.Json to System.Text.Json for deserializing scan manifest files. The change aligns with the broader codebase effort to support polymorphic deserialization of TypedComponent objects using System.Text.Json's built-in polymorphism support introduced in .NET 7+.

Key Changes

  • Removed Newtonsoft.Json using directive and replaced with System.Text.Json
  • Converted JsonConvert.DeserializeObject calls to JsonSerializer.Deserialize
  • Removed redundant fully-qualified namespace prefix from one deserialization call

@JamieMagee JamieMagee enabled auto-merge (squash) November 24, 2025 21:52
@JamieMagee JamieMagee merged commit 43986a4 into main Nov 24, 2025
32 of 33 checks passed
@JamieMagee JamieMagee deleted the users/jamagee/component-detection-integration-tests-system-text-json branch November 24, 2025 21:53
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