Skip to content

Conversation

@JamieMagee
Copy link
Member

  • LinuxScanner:
    • Replace JsonConvert.SerializeObject with JsonSerializer.Serialize
    • Replace JsonConvert.DeserializeObject with SyftOutput.FromJson()
    • Remove Newtonsoft.Json using directive
  • SyftOutput:
    • Regenerate from JSON schema using quicktype.io with System.Text.Json
    • Add [JsonPropertyName] attributes for proper property mapping
    • Add [JsonIgnore] attributes for null value handling
    • Add FromJson() helper method with case-insensitive parsing
    • Enable nullable reference types with appropriate pragmas
  • LinuxScannerTests:
    • Convert test JSON strings from escaped C# strings to raw literals
    • Fix property name casing to match schema (versionID vs versionId)
    • Remove trailing commas that were previously tolerated

See #231

- `LinuxScanner`:
  - Replace `JsonConvert.SerializeObject` with `JsonSerializer.Serialize`
  - Replace `JsonConvert.DeserializeObject` with `SyftOutput.FromJson()`
  - Remove `Newtonsoft.Json` using directive
- `SyftOutput`:
  - Regenerate from JSON schema using quicktype.io with `System.Text.Json`
  - Add `[JsonPropertyName]` attributes for proper property mapping
  - Add `[JsonIgnore]` attributes for null value handling
  - Add `FromJson()` helper method with case-insensitive parsing
  - Enable nullable reference types with appropriate pragmas
- `LinuxScannerTests`:
  - Convert test JSON strings from escaped C# strings to raw literals
  - Fix property name casing to match schema (`versionID` vs `versionId`)
  - Remove trailing commas that were previously tolerated

See #231
@JamieMagee JamieMagee requested a review from a team as a code owner November 25, 2025 21:21
@JamieMagee JamieMagee requested review from Copilot and jpinz November 25, 2025 21:21
Copilot finished reviewing on behalf of JamieMagee November 25, 2025 21:23
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.6%. Comparing base (9cf0b1d) to head (a9422fb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ComponentDetection.Detectors/linux/LinuxScanner.cs 66.6% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1567     +/-   ##
=======================================
- Coverage   90.1%   89.6%   -0.6%     
=======================================
  Files        426     426             
  Lines      35975   36256    +281     
  Branches    2221    2260     +39     
=======================================
+ Hits       32434   32494     +60     
- Misses      3080    3300    +220     
- Partials     461     462      +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 LinuxScanner component from Newtonsoft.Json to System.Text.Json, modernizing the JSON serialization approach. The changes include updating the LinuxScanner to use the new JSON APIs, regenerating the SyftOutput contract from the JSON schema with System.Text.Json attributes, and converting test JSON strings to use raw string literals while fixing property name casing.

Key changes:

  • Replaced JsonConvert methods with JsonSerializer and SyftOutput.FromJson() in LinuxScanner
  • Regenerated SyftOutput class with [JsonPropertyName] and [JsonIgnore] attributes, nullable reference types, and custom converters
  • Converted test JSON strings to raw literals and corrected property name casing (mostly to versionID)

Reviewed changes

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

File Description
LinuxScanner.cs Updated JSON serialization/deserialization to use System.Text.Json APIs
SyftOutput.cs Fully regenerated contract with System.Text.Json attributes, nullable support, and FromJson helper
LinuxScannerTests.cs Converted test JSON to raw literals and updated property names to match schema

@JamieMagee JamieMagee merged commit 32c05fb into main Nov 25, 2025
33 of 34 checks passed
@JamieMagee JamieMagee deleted the users/jamagee/linux-scanner-system-text-json branch November 25, 2025 22:17
@github-actions
Copy link

👋 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 🙂

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.

4 participants