Skip to content

Enable nullable types in Linux detector files#1709

Merged
jasonpaulos merged 1 commit intomainfrom
users/jasonpaulos/linux-enable-nullable
Mar 10, 2026
Merged

Enable nullable types in Linux detector files#1709
jasonpaulos merged 1 commit intomainfrom
users/jasonpaulos/linux-enable-nullable

Conversation

@jasonpaulos
Copy link
Member

Enable nullable types in Linux detector files

@jasonpaulos jasonpaulos requested a review from a team as a code owner March 10, 2026 16:03
@jasonpaulos jasonpaulos requested review from Copilot and melotic March 10, 2026 16:03
@github-actions
Copy link

github-actions bot commented Mar 10, 2026

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

Copy link
Contributor

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 enables nullable reference types across all Linux detector files by removing #nullable disable directives and adding the necessary nullable annotations to maintain type safety. This is part of the broader effort to enable nullable types throughout the codebase (as indicated by Nullable=enable in Directory.Build.props).

Changes:

  • Removed #nullable disable from all source files under src/Microsoft.ComponentDetection.Detectors/linux/ and their corresponding test files
  • Added nullable annotations (? and !) to return types, parameters, and local variables where needed (e.g., factory CreateComponent methods now return TypedComponent?, helper methods return string?)
  • Updated test files to use null! instead of null for non-nullable constructor parameters and added NotBeNull() assertions where needed

Reviewed changes

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

Show a summary per file
File Description
src/.../linux/ILinuxScanner.cs Removed #nullable disable
src/.../linux/LinuxScanner.cs Removed #nullable disable; added null-forgiving ! after .Where() filter; changed error return from null to []; made CreateComponentWithLayers return tuple TypedComponent?
src/.../linux/LinuxContainerDetector.cs Removed #nullable disable; added ! to Enum.GetName; simplified InvalidUserInputException to single-param ctor
src/.../linux/LinuxApplicationLayerDetector.cs Removed #nullable disable; added ! to all Enum.GetName calls
src/.../linux/Contracts/ImageScanningResult.cs Removed #nullable disable; ContainerDetailsContainerDetails?; Components initialized to []
src/.../linux/Exceptions/MissingContainerDetailException.cs Removed #nullable disable
src/.../linux/Factories/IArtifactComponentFactory.cs Removed #nullable disable; CreateComponent returns TypedComponent?
src/.../linux/Factories/ArtifactComponentFactoryBase.cs Removed #nullable disable; abstract CreateComponent returns TypedComponent?; helper methods return string?
src/.../linux/Factories/*.cs (9 factories) Removed #nullable disable; CreateComponent overrides return TypedComponent?; private helper return types updated
test/.../LinuxScannerTests.cs Removed #nullable disable; added BeOfType and NotBeNull assertions
test/.../LinuxContainerDetectorTests.cs Removed #nullable disable; updated Func<..., Exception?, string> in mock verifications
test/.../LinuxApplicationLayerExperimentTests.cs Removed #nullable disable; changed null to null! for constructor args

@jasonpaulos jasonpaulos merged commit f2d7419 into main Mar 10, 2026
33 of 36 checks passed
@jasonpaulos jasonpaulos deleted the users/jasonpaulos/linux-enable-nullable branch March 10, 2026 17:21
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.0%. Comparing base (3d2cdeb) to head (79ef6a6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #1709   +/-   ##
============================
============================

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

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