Skip to content
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

Add DotNetComponent #1363

Merged
merged 8 commits into from
Mar 5, 2025
Merged

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented Feb 27, 2025

The DotNetComponent type is used to report usage of the .NET SDK version

This is important as the .NET SDK will add redistributable content to the project, so using an older version may mean your application contains unserviced copies of the host or runtime. The TargetFramework and project type is reported as well since these influence what content the SDK may reference.

Some remaining work:

  • Add documentation
  • Support concurrency (protect cache)
  • More tests - bad assembly, shared files under same global.json/root, ensure we halt global.json search appropriately.
  • Answer question about PURL

The DotNetComponent type is used to report usage of the .NET SDK version

This is important as the .NET SDK will add redistributable content to
the project, so using an older version may mean your application
contains unserviced copies of the host or runtime.
The TargetFramework and project type is reported as well since these
influence what content the SDK may reference.
@ericstj ericstj requested a review from Copilot February 27, 2025 22:28
Copy link

@Copilot 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.

PR Overview

This PR adds the DotNetComponent type and its corresponding detector along with tests and service configuration to enable detection of .NET SDK usage and project details. Key changes include:

  • Introduction of DotNetComponent with properties for SDK version, target framework, and project type.
  • Creation of DotNetComponentDetector to analyze project assets and global.json for .NET SDK version discovery.
  • Addition of unit tests and configuration updates to wire up the new detector.

Reviewed Changes

File Description
src/Microsoft.ComponentDetection.Contracts/TypedComponent/DotNetComponent.cs Added new DotNetComponent type with an Id property and PackageURL implementation.
src/Microsoft.ComponentDetection.Orchestrator/Experiments/DotNetDetectorExperiment.cs Added a new experimental configuration for the .NET detector.
src/Microsoft.ComponentDetection.Detectors/dotnet/DotNetComponentDetector.cs Introduced the DotNetComponentDetector to process .NET project files and determine the SDK version.
test/Microsoft.ComponentDetection.Detectors.Tests/DotNetComponentDetectorTests.cs Added unit tests to validate the behavior of the new detector.
src/Microsoft.ComponentDetection.Contracts/TypedComponent/ComponentType.cs Updated enum to include the new DotNet component type.
src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs Updated service registrations to include the new .NET detector and experiment.
src/Microsoft.ComponentDetection.Detectors/yarn/YarnLockComponentDetector.cs Minor update to namespace import using global qualifier.
src/Microsoft.ComponentDetection.Common/CommandLineInvocationService.cs Fixed parameter usage in command location check.

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 94.91150% with 23 lines in your changes missing coverage. Please review.

Project coverage is 89.5%. Comparing base (ed22500) to head (0d69459).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ection.Detectors/dotnet/DotNetComponentDetector.cs 88.8% 7 Missing and 7 partials ⚠️
...ection.Contracts/TypedComponent/DotNetComponent.cs 64.7% 5 Missing and 1 partial ⚠️
...on.Detectors.Tests/DotNetComponentDetectorTests.cs 99.0% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #1363    +/-   ##
======================================
  Coverage   89.4%   89.5%            
======================================
  Files        398     402     +4     
  Lines      31029   31480   +451     
  Branches    1869    1928    +59     
======================================
+ Hits       27757   28183   +426     
- Misses      2867    2879    +12     
- Partials     405     418    +13     

☔ 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.

@ericstj ericstj force-pushed the DotNetComponentExperiment branch from b31822a to 342e415 Compare March 4, 2025 04:38
@ericstj ericstj marked this pull request as ready for review March 5, 2025 00:10
@ericstj ericstj requested a review from a team as a code owner March 5, 2025 00:10
Copy link

@Copilot 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.

PR Overview

This PR introduces a new DotNetComponent and its corresponding detector, enabling detection and reporting of the .NET SDK version as well as related project data. Changes include implementation of the DotNetComponent type, creation of a DotNetComponentDetector with caching and concurrency support, and necessary updates to documentation and service registration.

Reviewed Changes

File Description
src/Microsoft.ComponentDetection.Contracts/TypedComponent/DotNetComponent.cs Adds a new component type to capture .NET SDK, TargetFramework, and ProjectType information.
docs/detectors/dotnet.md Provides documentation regarding DotNet SDK detection and its strategy.
src/Microsoft.ComponentDetection.Orchestrator/Experiments/DotNetDetectorExperiment.cs Introduces an experiment configuration for the new DotNet detector.
src/Microsoft.ComponentDetection.Detectors/dotnet/DotNetComponentDetector.cs Implements a new detector for DotNet components with caching and recursive SDK version lookup.
src/Microsoft.ComponentDetection.Contracts/TypedComponent/ComponentType.cs Extends the enum with a new DotNet value.
src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs Registers the new DotNet detector and experiment in the service collection.
src/Microsoft.ComponentDetection.Detectors/yarn/YarnLockComponentDetector.cs Updates the using directive to correctly reference the DotNet.Globbing namespace.
src/Microsoft.ComponentDetection.Common/CommandLineInvocationService.cs Modifies execution call parameters to pass along the working directory.

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

@grvillic grvillic enabled auto-merge (squash) March 5, 2025 20:22
@grvillic grvillic disabled auto-merge March 5, 2025 20:22
@grvillic grvillic merged commit 255e011 into microsoft:main Mar 5, 2025
20 of 23 checks passed
Copy link

github-actions bot commented Mar 5, 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 🙂

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.

2 participants