Skip to content

Conversation

@AndyGerlicher
Copy link
Member

Currently the DotNetComponentDetector fails for trailing commas parsing global.json. An example I hit:

{
  // Defines version of MSBuild project SDKs to use
  // https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2017#how-project-sdks-are-resolved
  // https://docs.microsoft.com/en-us/dotnet/core/tools/global-json#globaljson-schema
  "msbuild-sdks": {
    "Microsoft.Build.Traversal": "4.1.82",
    "Microsoft.Build.NoTargets": "3.7.134"
  },
}

Copilot AI review requested due to automatic review settings November 19, 2025 17:49
@AndyGerlicher AndyGerlicher requested a review from a team as a code owner November 19, 2025 17:49
Copilot finished reviewing on behalf of AndyGerlicher November 19, 2025 17:52
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.2%. Comparing base (07d23ff) to head (ef76890).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1545   +/-   ##
=====================================
  Coverage   90.2%   90.2%           
=====================================
  Files        423     423           
  Lines      35452   35476   +24     
  Branches    2207    2209    +2     
=====================================
+ Hits       31997   32020   +23     
  Misses      3001    3001           
- Partials     454     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.

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 fixes a bug where the DotNetComponentDetector failed to parse global.json files containing trailing commas. The fix enables trailing comma support in the JSON parser, and adds test coverage for this scenario.

  • Added AllowTrailingCommas = true to the JSON parser options used for global.json parsing
  • Added a new test case TestDotNetDetectorGlobalJsonWithTrailingCommas_ReturnsSDKVersion to verify the fix

Reviewed Changes

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

File Description
src/Microsoft.ComponentDetection.Detectors/dotnet/DotNetComponentDetector.cs Updated JsonDocumentOptions to allow trailing commas in addition to existing comment handling support
test/Microsoft.ComponentDetection.Detectors.Tests/DotNetComponentDetectorTests.cs Added test case to verify global.json files with trailing commas are parsed successfully

@JamieMagee JamieMagee merged commit 43a01d6 into microsoft:main Nov 19, 2025
29 of 30 checks passed
@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.

3 participants