diff --git a/Directory.Packages.props b/Directory.Packages.props
index 37c5d28d..5f279626 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -52,7 +52,6 @@
-
diff --git a/src/Microsoft.ComponentDetection.Common/Column.cs b/src/Microsoft.ComponentDetection.Common/Column.cs
index 4554f71c..4ce0cac2 100644
--- a/src/Microsoft.ComponentDetection.Common/Column.cs
+++ b/src/Microsoft.ComponentDetection.Common/Column.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
public class Column
{
diff --git a/src/Microsoft.ComponentDetection.Common/ComponentComparer.cs b/src/Microsoft.ComponentDetection.Common/ComponentComparer.cs
index fcb9485c..8e03c910 100644
--- a/src/Microsoft.ComponentDetection.Common/ComponentComparer.cs
+++ b/src/Microsoft.ComponentDetection.Common/ComponentComparer.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System.Collections.Generic;
using Microsoft.ComponentDetection.Contracts.TypedComponent;
diff --git a/src/Microsoft.ComponentDetection.Common/ComponentStream.cs b/src/Microsoft.ComponentDetection.Common/ComponentStream.cs
index f9f0d9e8..8c18db62 100644
--- a/src/Microsoft.ComponentDetection.Common/ComponentStream.cs
+++ b/src/Microsoft.ComponentDetection.Common/ComponentStream.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System.IO;
using Microsoft.ComponentDetection.Contracts;
diff --git a/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerable.cs b/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerable.cs
index 7afd066f..ade05d0e 100644
--- a/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerable.cs
+++ b/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerable.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System;
using System.Collections;
diff --git a/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerableFactory.cs b/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerableFactory.cs
index 18030d77..318394f2 100644
--- a/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerableFactory.cs
+++ b/src/Microsoft.ComponentDetection.Common/ComponentStreamEnumerableFactory.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Common/DependencyGraph/ComponentRecorder.cs b/src/Microsoft.ComponentDetection.Common/DependencyGraph/ComponentRecorder.cs
index 0ebbe87f..8f58b3bc 100644
--- a/src/Microsoft.ComponentDetection.Common/DependencyGraph/ComponentRecorder.cs
+++ b/src/Microsoft.ComponentDetection.Common/DependencyGraph/ComponentRecorder.cs
@@ -172,12 +172,12 @@ public class ComponentRecorder : IComponentRecorder
#if DEBUG
if (detectedComponent.DependencyRoots is null || detectedComponent.DependencyRoots.Count == 0)
{
- this.logger.LogWarning("Detector should not populate DetectedComponent.DependencyRoots!");
+ this.logger?.LogWarning("Detector should not populate DetectedComponent.DependencyRoots!");
}
if (detectedComponent.DevelopmentDependency.HasValue)
{
- this.logger.LogWarning("Detector should not populate DetectedComponent.DevelopmentDependency!");
+ this.logger?.LogWarning("Detector should not populate DetectedComponent.DevelopmentDependency!");
}
#endif
diff --git a/src/Microsoft.ComponentDetection.Common/DependencyScopeComparer.cs b/src/Microsoft.ComponentDetection.Common/DependencyScopeComparer.cs
index 6cf6fafe..79a0090a 100644
--- a/src/Microsoft.ComponentDetection.Common/DependencyScopeComparer.cs
+++ b/src/Microsoft.ComponentDetection.Common/DependencyScopeComparer.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using Microsoft.ComponentDetection.Contracts.BcdeModels;
diff --git a/src/Microsoft.ComponentDetection.Common/DirectoryItemFacade.cs b/src/Microsoft.ComponentDetection.Common/DirectoryItemFacade.cs
index 13e388f6..06dc4115 100644
--- a/src/Microsoft.ComponentDetection.Common/DirectoryItemFacade.cs
+++ b/src/Microsoft.ComponentDetection.Common/DirectoryItemFacade.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Microsoft.ComponentDetection.Common/IConsoleWritingService.cs b/src/Microsoft.ComponentDetection.Common/IConsoleWritingService.cs
index 4a62593f..83d70634 100644
--- a/src/Microsoft.ComponentDetection.Common/IConsoleWritingService.cs
+++ b/src/Microsoft.ComponentDetection.Common/IConsoleWritingService.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
public interface IConsoleWritingService
{
diff --git a/src/Microsoft.ComponentDetection.Common/ISafeFileEnumerableFactory.cs b/src/Microsoft.ComponentDetection.Common/ISafeFileEnumerableFactory.cs
index 98588d34..5cd277f4 100644
--- a/src/Microsoft.ComponentDetection.Common/ISafeFileEnumerableFactory.cs
+++ b/src/Microsoft.ComponentDetection.Common/ISafeFileEnumerableFactory.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System.Collections.Generic;
using System.IO;
diff --git a/src/Microsoft.ComponentDetection.Common/MatchedFile.cs b/src/Microsoft.ComponentDetection.Common/MatchedFile.cs
index ec66ea8e..8b8b6cc6 100644
--- a/src/Microsoft.ComponentDetection.Common/MatchedFile.cs
+++ b/src/Microsoft.ComponentDetection.Common/MatchedFile.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System.IO;
diff --git a/src/Microsoft.ComponentDetection.Common/ScanType.cs b/src/Microsoft.ComponentDetection.Common/ScanType.cs
index b61f7c87..b3a2d696 100644
--- a/src/Microsoft.ComponentDetection.Common/ScanType.cs
+++ b/src/Microsoft.ComponentDetection.Common/ScanType.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
public enum ScanType
{
diff --git a/src/Microsoft.ComponentDetection.Common/TabularStringFormat.cs b/src/Microsoft.ComponentDetection.Common/TabularStringFormat.cs
index 07ad56fc..d60f5647 100644
--- a/src/Microsoft.ComponentDetection.Common/TabularStringFormat.cs
+++ b/src/Microsoft.ComponentDetection.Common/TabularStringFormat.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Attributes/MetricAttribute.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Attributes/MetricAttribute.cs
index 6a8f1b90..e6ee53a2 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Attributes/MetricAttribute.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Attributes/MetricAttribute.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Attributes;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Attributes;
using System;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/CommandLineTelemetryService.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/CommandLineTelemetryService.cs
index 0d537c52..7fc21dc2 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/CommandLineTelemetryService.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/CommandLineTelemetryService.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry;
+namespace Microsoft.ComponentDetection.Common.Telemetry;
using System;
using System.Collections.Concurrent;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/ITelemetryService.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/ITelemetryService.cs
index e6251350..370c13d4 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/ITelemetryService.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/ITelemetryService.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry;
+namespace Microsoft.ComponentDetection.Common.Telemetry;
using Microsoft.ComponentDetection.Common.Telemetry.Records;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BaseDetectionTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BaseDetectionTelemetryRecord.cs
index 8ba43a9e..be340269 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BaseDetectionTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BaseDetectionTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System;
using System.Diagnostics;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BcdeExecutionTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BcdeExecutionTelemetryRecord.cs
index ab67b8d2..69aefc6a 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BcdeExecutionTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/BcdeExecutionTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/CommandLineInvocationTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/CommandLineInvocationTelemetryRecord.cs
index a26f840b..e4745f7f 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/CommandLineInvocationTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/CommandLineInvocationTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System;
using Microsoft.ComponentDetection.Contracts;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectedComponentScopeRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectedComponentScopeRecord.cs
index 4a2aaa8e..94c43727 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectedComponentScopeRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectedComponentScopeRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System.Runtime.CompilerServices;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectorExecutionTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectorExecutionTelemetryRecord.cs
index 4c9060b5..cbed3d3b 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectorExecutionTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/DetectorExecutionTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class DetectorExecutionTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/GoGraphTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/GoGraphTelemetryRecord.cs
index bef83e60..1edaf2a1 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/GoGraphTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/GoGraphTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class GoGraphTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/IDetectionTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/IDetectionTelemetryRecord.cs
index 27d072bc..2056aff1 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/IDetectionTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/IDetectionTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorImageDetectionFailed.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorImageDetectionFailed.cs
index 774706cf..5da8f7e9 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorImageDetectionFailed.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorImageDetectionFailed.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class LinuxContainerDetectorImageDetectionFailed : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingRepoNameAndTagRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingRepoNameAndTagRecord.cs
index 132c30c6..6d64ae1a 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingRepoNameAndTagRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingRepoNameAndTagRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class LinuxContainerDetectorMissingRepoNameAndTagRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingVersion.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingVersion.cs
index abe41459..d4133c8a 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingVersion.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorMissingVersion.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class LinuxContainerDetectorMissingVersion : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorTimeout.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorTimeout.cs
index 9ddc38a8..4e91d612 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorTimeout.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorTimeout.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class LinuxContainerDetectorTimeout : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorUnsupportedOs.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorUnsupportedOs.cs
index d6758426..59b61bd0 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorUnsupportedOs.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxContainerDetectorUnsupportedOs.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class LinuxContainerDetectorUnsupportedOs : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxScannerTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxScannerTelemetryRecord.cs
index 46d343ee..b5d7ab5d 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxScannerTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LinuxScannerTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class LinuxScannerTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LoadComponentDetectorsTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LoadComponentDetectorsTelemetryRecord.cs
index f85d80e2..019ac304 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LoadComponentDetectorsTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/LoadComponentDetectorsTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class LoadComponentDetectorsTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/NuGetProjectAssetsTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/NuGetProjectAssetsTelemetryRecord.cs
index fd2c16e6..3759a402 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/NuGetProjectAssetsTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/NuGetProjectAssetsTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PyPiCacheTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PyPiCacheTelemetryRecord.cs
index 28093d45..ff0a5920 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PyPiCacheTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PyPiCacheTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class PypiCacheTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiFailureTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiFailureTelemetryRecord.cs
index 5f78a246..834d02d1 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiFailureTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiFailureTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System.Net;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiMaxRetriesReachedTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiMaxRetriesReachedTelemetryRecord.cs
index 5b0fd92f..e49973c5 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiMaxRetriesReachedTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiMaxRetriesReachedTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class PypiMaxRetriesReachedTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiRetryTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiRetryTelemetryRecord.cs
index 15552b8e..d60d18a0 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiRetryTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/PypiRetryTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
using System.Net;
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustCrateDetectorTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustCrateDetectorTelemetryRecord.cs
index 08d3c8e4..9ee6ef2c 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustCrateDetectorTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustCrateDetectorTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class RustCrateDetectorTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustGraphTelemetryRecord.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustGraphTelemetryRecord.cs
index 0b09cc9e..92d92ef5 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustGraphTelemetryRecord.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/Records/RustGraphTelemetryRecord.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
+namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
public class RustGraphTelemetryRecord : BaseDetectionTelemetryRecord
{
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryConstants.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryConstants.cs
index 96c1c76b..1ba30666 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryConstants.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryConstants.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.ComponentDetection.Orchestrator")]
diff --git a/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryMode.cs b/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryMode.cs
index 1d628596..f68cc670 100644
--- a/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryMode.cs
+++ b/src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryMode.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common.Telemetry;
+namespace Microsoft.ComponentDetection.Common.Telemetry;
public enum TelemetryMode
{
diff --git a/src/Microsoft.ComponentDetection.Common/WarnOnAlertSeverity.cs b/src/Microsoft.ComponentDetection.Common/WarnOnAlertSeverity.cs
index 65ceab80..a66601bf 100644
--- a/src/Microsoft.ComponentDetection.Common/WarnOnAlertSeverity.cs
+++ b/src/Microsoft.ComponentDetection.Common/WarnOnAlertSeverity.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Common;
+namespace Microsoft.ComponentDetection.Common;
public enum WarnOnAlertSeverity
{
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/ContainerDetails.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/ContainerDetails.cs
index 331830cb..ac3ea4ed 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/ContainerDetails.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/ContainerDetails.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DefaultGraphScanResult.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DefaultGraphScanResult.cs
index 7e07692d..e009f2ee 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DefaultGraphScanResult.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DefaultGraphScanResult.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraph.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraph.cs
index 06ebbf31..c98abf0c 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraph.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraph.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphCollection.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphCollection.cs
index b1ccaced..f384d97d 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphCollection.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphCollection.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphWithMetadata.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphWithMetadata.cs
index 2358cb9e..b850ff67 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphWithMetadata.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyGraphWithMetadata.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
using System.Collections.Generic;
using Newtonsoft.Json;
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyScope.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyScope.cs
index 6fa95e39..bbb56ab9 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyScope.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/DependencyScope.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
/// Used to communicate Dependency Scope of Component.
/// Currently only populated for Maven component.
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/Detector.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/Detector.cs
index f350eb56..b2636cf0 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/Detector.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/Detector.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
using System.Collections.Generic;
using Microsoft.ComponentDetection.Contracts.TypedComponent;
diff --git a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/TypedComponentConverter.cs b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/TypedComponentConverter.cs
index 0ed8aa09..4e15e897 100644
--- a/src/Microsoft.ComponentDetection.Contracts/BcdeModels/TypedComponentConverter.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/BcdeModels/TypedComponentConverter.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
+namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Contracts/DetectorClass.cs b/src/Microsoft.ComponentDetection.Contracts/DetectorClass.cs
index 3da44b17..cde85fd5 100644
--- a/src/Microsoft.ComponentDetection.Contracts/DetectorClass.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/DetectorClass.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts;
+namespace Microsoft.ComponentDetection.Contracts;
/// Class of detector, the names of which are converted into categories for all default detectors.
public enum DetectorClass
diff --git a/src/Microsoft.ComponentDetection.Contracts/IComponentStream.cs b/src/Microsoft.ComponentDetection.Contracts/IComponentStream.cs
index 2660e18d..c5abf722 100644
--- a/src/Microsoft.ComponentDetection.Contracts/IComponentStream.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/IComponentStream.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts;
+namespace Microsoft.ComponentDetection.Contracts;
using System.IO;
diff --git a/src/Microsoft.ComponentDetection.Contracts/IComponentStreamEnumerableFactory.cs b/src/Microsoft.ComponentDetection.Contracts/IComponentStreamEnumerableFactory.cs
index 66de20f7..9f317442 100644
--- a/src/Microsoft.ComponentDetection.Contracts/IComponentStreamEnumerableFactory.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/IComponentStreamEnumerableFactory.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts;
+namespace Microsoft.ComponentDetection.Contracts;
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Contracts/IObservableDirectoryWalkerFactory.cs b/src/Microsoft.ComponentDetection.Contracts/IObservableDirectoryWalkerFactory.cs
index 50db2a92..45a06fbc 100644
--- a/src/Microsoft.ComponentDetection.Contracts/IObservableDirectoryWalkerFactory.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/IObservableDirectoryWalkerFactory.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts;
+namespace Microsoft.ComponentDetection.Contracts;
using System;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Contracts/Internal/NpmAuthor.cs b/src/Microsoft.ComponentDetection.Contracts/Internal/NpmAuthor.cs
index e421fa35..7dd6ab3b 100644
--- a/src/Microsoft.ComponentDetection.Contracts/Internal/NpmAuthor.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/Internal/NpmAuthor.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.Internal;
+namespace Microsoft.ComponentDetection.Contracts.Internal;
using System;
diff --git a/src/Microsoft.ComponentDetection.Contracts/Internal/ProcessRequest.cs b/src/Microsoft.ComponentDetection.Contracts/Internal/ProcessRequest.cs
index d878396f..1a727f80 100644
--- a/src/Microsoft.ComponentDetection.Contracts/Internal/ProcessRequest.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/Internal/ProcessRequest.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.Internal;
+namespace Microsoft.ComponentDetection.Contracts.Internal;
public class ProcessRequest
{
diff --git a/src/Microsoft.ComponentDetection.Contracts/KillSwitchConfiguration.cs b/src/Microsoft.ComponentDetection.Contracts/KillSwitchConfiguration.cs
index 04fe243e..107539ec 100644
--- a/src/Microsoft.ComponentDetection.Contracts/KillSwitchConfiguration.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/KillSwitchConfiguration.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts;
+namespace Microsoft.ComponentDetection.Contracts;
///
/// Represents the configuration for the kill switch.
diff --git a/src/Microsoft.ComponentDetection.Contracts/ProcessingResultCode.cs b/src/Microsoft.ComponentDetection.Contracts/ProcessingResultCode.cs
index 4d2e9c8a..9836d635 100644
--- a/src/Microsoft.ComponentDetection.Contracts/ProcessingResultCode.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/ProcessingResultCode.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts;
+namespace Microsoft.ComponentDetection.Contracts;
/// Code used to communicate the state of a scan after completion.
public enum ProcessingResultCode
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/ComponentType.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/ComponentType.cs
index 371ad836..3d3593c7 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/ComponentType.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/ComponentType.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using System.Runtime.Serialization;
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/CondaComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/CondaComponent.cs
index 3ffc1956..04edb3f7 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/CondaComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/CondaComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
public class CondaComponent : TypedComponent
{
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GitComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GitComponent.cs
index d41cf5cf..aeee1683 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GitComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GitComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using System;
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GoComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GoComponent.cs
index dcb9066a..6246ef70 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GoComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/GoComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using System;
using PackageUrl;
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/MavenComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/MavenComponent.cs
index 0e77a77b..b0273065 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/MavenComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/MavenComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using PackageUrl;
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NpmComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NpmComponent.cs
index 427370b4..e758eeda 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NpmComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NpmComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using Microsoft.ComponentDetection.Contracts.Internal;
using PackageUrl;
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NugetComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NugetComponent.cs
index 8ba4dfd5..dad78752 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NugetComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/NugetComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using PackageUrl;
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/PodComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/PodComponent.cs
index ca02e5cc..63b00d3c 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/PodComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/PodComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using System.Collections.Generic;
using PackageUrl;
diff --git a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/SpdxComponent.cs b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/SpdxComponent.cs
index 6fa8475e..c4328bfb 100644
--- a/src/Microsoft.ComponentDetection.Contracts/TypedComponent/SpdxComponent.cs
+++ b/src/Microsoft.ComponentDetection.Contracts/TypedComponent/SpdxComponent.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
+namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
using System;
diff --git a/src/Microsoft.ComponentDetection.Detectors/cocoapods/PodComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/cocoapods/PodComponentDetector.cs
index ecd6091a..491a3a0c 100644
--- a/src/Microsoft.ComponentDetection.Detectors/cocoapods/PodComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/cocoapods/PodComponentDetector.cs
@@ -29,11 +29,11 @@ public class PodComponentDetector : FileComponentDetector
public override string Id { get; } = "CocoaPods";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.CocoaPods) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.CocoaPods)];
- public override IList SearchPatterns { get; } = new List { "Podfile.lock" };
+ public override IList SearchPatterns { get; } = ["Podfile.lock"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Pod, ComponentType.Git };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Pod, ComponentType.Git];
public override int Version { get; } = 2;
@@ -225,7 +225,7 @@ public class PodComponentDetector : FileComponentDetector
foreach (var pod in podDependencies)
{
// Add all the dependencies to the map, without duplicates
- dependenciesMap.TryAdd(pod.Key, new HashSet());
+ dependenciesMap.TryAdd(pod.Key, []);
foreach (var dependency in pod.Value)
{
diff --git a/src/Microsoft.ComponentDetection.Detectors/conan/ConanLockComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/conan/ConanLockComponentDetector.cs
index 232615b4..21d622d5 100644
--- a/src/Microsoft.ComponentDetection.Detectors/conan/ConanLockComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/conan/ConanLockComponentDetector.cs
@@ -26,13 +26,13 @@ public class ConanLockComponentDetector : FileComponentDetector, IDefaultOffComp
public override string Id => "ConanLock";
- public override IList SearchPatterns => new List { "conan.lock" };
+ public override IList SearchPatterns => ["conan.lock"];
- public override IEnumerable SupportedComponentTypes => new[] { ComponentType.Conan };
+ public override IEnumerable SupportedComponentTypes => [ComponentType.Conan];
public override int Version { get; } = 1;
- public override IEnumerable Categories => new List { "Conan" };
+ public override IEnumerable Categories => ["Conan"];
protected override async Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary detectorArgs, CancellationToken cancellationToken = default)
{
@@ -52,9 +52,8 @@ public class ConanLockComponentDetector : FileComponentDetector, IDefaultOffComp
var packagesDictionary = conanLock.GraphLock.Nodes;
var explicitReferencedDependencies = new HashSet();
var developmentDependencies = new HashSet();
- if (packagesDictionary.ContainsKey("0"))
+ if (packagesDictionary.Remove("0", out var rootNode))
{
- packagesDictionary.Remove("0", out var rootNode);
if (rootNode?.Requires != null)
{
explicitReferencedDependencies = new HashSet(rootNode.Requires);
diff --git a/src/Microsoft.ComponentDetection.Detectors/conda/CondaDependencyResolver.cs b/src/Microsoft.ComponentDetection.Detectors/conda/CondaDependencyResolver.cs
index 60ffb84b..64a442fc 100644
--- a/src/Microsoft.ComponentDetection.Detectors/conda/CondaDependencyResolver.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/conda/CondaDependencyResolver.cs
@@ -28,7 +28,7 @@ public static class CondaDependencyResolver
public static void UpdateDirectlyReferencedPackages(ISingleFileComponentRecorder singleFileComponentRecorder)
=> singleFileComponentRecorder.GetDetectedComponents().Keys.ForEach(componentId =>
{
- if (!singleFileComponentRecorder.DependencyGraph.GetAncestors(componentId).Any())
+ if (singleFileComponentRecorder.DependencyGraph.GetAncestors(componentId).Count == 0)
{
singleFileComponentRecorder.RegisterUsage(
singleFileComponentRecorder.GetComponent(componentId),
@@ -100,7 +100,7 @@ public static class CondaDependencyResolver
/// A list of packages without dependencies.
private static List GetPackages(CondaLock condaLock)
=> condaLock?.Package == null
- ? new List()
+ ? []
: condaLock.Package;
///
diff --git a/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs
index db0a1269..6a5ab362 100644
--- a/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs
@@ -27,13 +27,13 @@ public class CondaLockComponentDetector : FileComponentDetector, IDefaultOffComp
public override string Id => "CondaLock";
- public override IList SearchPatterns { get; } = new List { "conda-lock.yml", "*.conda-lock.yml" };
+ public override IList SearchPatterns { get; } = ["conda-lock.yml", "*.conda-lock.yml"];
- public override IEnumerable SupportedComponentTypes => new[] { ComponentType.Conda, ComponentType.Pip };
+ public override IEnumerable SupportedComponentTypes => [ComponentType.Conda, ComponentType.Pip];
public override int Version { get; } = 2;
- public override IEnumerable Categories => new List { "Python" };
+ public override IEnumerable Categories => ["Python"];
///
protected override Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary detectorArgs, CancellationToken cancellationToken = default)
diff --git a/src/Microsoft.ComponentDetection.Detectors/dockerfile/DockerfileComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/dockerfile/DockerfileComponentDetector.cs
index 65921192..7826a382 100644
--- a/src/Microsoft.ComponentDetection.Detectors/dockerfile/DockerfileComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/dockerfile/DockerfileComponentDetector.cs
@@ -35,11 +35,11 @@ public class DockerfileComponentDetector : FileComponentDetector, IDefaultOffCom
public override string Id { get; } = "DockerReference";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.DockerReference) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.DockerReference)];
- public override IList SearchPatterns { get; } = new List { "dockerfile", "dockerfile.*", "*.dockerfile" };
+ public override IList SearchPatterns { get; } = ["dockerfile", "dockerfile.*", "*.dockerfile"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.DockerReference };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.DockerReference];
public override int Version => 1;
@@ -55,7 +55,7 @@ public class DockerfileComponentDetector : FileComponentDetector, IDefaultOffCom
string contents;
using (var reader = new StreamReader(file.Stream))
{
- contents = await reader.ReadToEndAsync();
+ contents = await reader.ReadToEndAsync(cancellationToken);
}
var stageNameMap = new Dictionary();
@@ -69,7 +69,7 @@ public class DockerfileComponentDetector : FileComponentDetector, IDefaultOffCom
private Task ParseDockerFileAsync(string fileContents, string fileLocation, ISingleFileComponentRecorder singleFileComponentRecorder, Dictionary stageNameMap)
{
- var dockerfileModel = Valleysoft.DockerfileModel.Dockerfile.Parse(fileContents);
+ var dockerfileModel = Dockerfile.Parse(fileContents);
var instructions = dockerfileModel.Items;
foreach (var instruction in instructions)
{
diff --git a/src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs
index 523a784c..abfd9b70 100644
--- a/src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs
@@ -23,7 +23,7 @@ public class GoComponentDetector : FileComponentDetector
@"(?.*)\s+(?.*?)(/go\.mod)?\s+(?.*)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
- private readonly HashSet projectRoots = new();
+ private readonly HashSet projectRoots = [];
private readonly ICommandLineInvocationService commandLineInvocationService;
private readonly IEnvironmentVariableService envVarService;
@@ -44,11 +44,11 @@ public class GoComponentDetector : FileComponentDetector
public override string Id => "Go";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod)];
- public override IList SearchPatterns { get; } = new List { "go.mod", "go.sum" };
+ public override IList SearchPatterns { get; } = ["go.mod", "go.sum"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Go };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Go];
public override int Version => 7;
@@ -90,7 +90,7 @@ public class GoComponentDetector : FileComponentDetector
private IEnumerable FindAdjacentGoModComponentStreams(ProcessRequest processRequest) =>
this.ComponentStreamEnumerableFactory.GetComponentStreams(
new FileInfo(processRequest.ComponentStream.Location).Directory,
- new[] { "go.mod" },
+ ["go.mod"],
(_, _) => false,
false)
.Select(x =>
@@ -224,7 +224,7 @@ public class GoComponentDetector : FileComponentDetector
var projectRootDirectory = Directory.GetParent(location);
record.ProjectRoot = projectRootDirectory.FullName;
- var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, new[] { "version" });
+ var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, ["version"]);
record.IsGoAvailable = isGoAvailable;
if (!isGoAvailable)
@@ -236,7 +236,7 @@ public class GoComponentDetector : FileComponentDetector
this.Logger.LogInformation("Go CLI was found in system and will be used to generate dependency graph. " +
"Detection time may be improved by activating fallback strategy (https://github.com/microsoft/component-detection/blob/main/docs/detectors/go.md#fallback-detection-strategy). " +
"But, it will introduce noise into the detected components.");
- var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, new[] { "list", "-mod=readonly", "-m", "-json", "all" });
+ var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, ["list", "-mod=readonly", "-m", "-json", "all"]);
if (goDependenciesProcess.ExitCode != 0)
{
this.Logger.LogError("Go CLI command \"go list -m -json all\" failed with error: {GoDependenciesProcessStdErr}", goDependenciesProcess.StdErr);
@@ -308,7 +308,7 @@ public class GoComponentDetector : FileComponentDetector
}
// Stopping at the first ) restrict the detection to only the require section.
- while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(")"))
+ while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(')'))
{
this.TryRegisterDependencyFromModLine(line, singleFileComponentRecorder);
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/go/GoComponentWithReplaceDetector.cs b/src/Microsoft.ComponentDetection.Detectors/go/GoComponentWithReplaceDetector.cs
index eed69fba..12849535 100644
--- a/src/Microsoft.ComponentDetection.Detectors/go/GoComponentWithReplaceDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/go/GoComponentWithReplaceDetector.cs
@@ -23,7 +23,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
@"(?.*)\s+(?.*?)(/go\.mod)?\s+(?.*)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
- private readonly HashSet projectRoots = new();
+ private readonly HashSet projectRoots = [];
private readonly ICommandLineInvocationService commandLineInvocationService;
private readonly IEnvironmentVariableService envVarService;
@@ -44,11 +44,11 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
public override string Id => "GoWithReplace";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod)];
- public override IList SearchPatterns { get; } = new List { "go.mod", "go.sum" };
+ public override IList SearchPatterns { get; } = ["go.mod", "go.sum"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Go };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Go];
public override int Version => 1;
@@ -90,7 +90,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
private IEnumerable FindAdjacentGoModComponentStreams(ProcessRequest processRequest) =>
this.ComponentStreamEnumerableFactory.GetComponentStreams(
new FileInfo(processRequest.ComponentStream.Location).Directory,
- new[] { "go.mod" },
+ ["go.mod"],
(_, _) => false,
false)
.Select(x =>
@@ -224,7 +224,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
var projectRootDirectory = Directory.GetParent(location);
record.ProjectRoot = projectRootDirectory.FullName;
- var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, new[] { "version" });
+ var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, ["version"]);
record.IsGoAvailable = isGoAvailable;
if (!isGoAvailable)
@@ -236,7 +236,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
this.Logger.LogInformation("Go CLI was found in system and will be used to generate dependency graph. " +
"Detection time may be improved by activating fallback strategy (https://github.com/microsoft/component-detection/blob/main/docs/detectors/go.md#fallback-detection-strategy). " +
"But, it will introduce noise into the detected components.");
- var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, new[] { "list", "-mod=readonly", "-m", "-json", "all" });
+ var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, ["list", "-mod=readonly", "-m", "-json", "all"]);
if (goDependenciesProcess.ExitCode != 0)
{
this.Logger.LogError("Go CLI command \"go list -m -json all\" failed with error: {GoDependenciesProcessStdErr}", goDependenciesProcess.StdErr);
@@ -309,7 +309,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
}
// Stopping at the first ) restrict the detection to only the require section.
- while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(")"))
+ while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(')'))
{
this.TryRegisterDependencyFromModLine(line, singleFileComponentRecorder);
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/gradle/GradleComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/gradle/GradleComponentDetector.cs
index 9a7fb9b3..f01f9f94 100644
--- a/src/Microsoft.ComponentDetection.Detectors/gradle/GradleComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/gradle/GradleComponentDetector.cs
@@ -31,19 +31,19 @@ public class GradleComponentDetector : FileComponentDetector, IComponentDetector
this.Scanner = walkerFactory;
this.Logger = logger;
- this.devLockfiles = envVarService.GetListEnvironmentVariable(DevLockfilesEnvVar) ?? new List();
- this.devConfigurations = envVarService.GetListEnvironmentVariable(DevConfigurationsEnvVar) ?? new List();
+ this.devLockfiles = envVarService.GetListEnvironmentVariable(DevLockfilesEnvVar) ?? [];
+ this.devConfigurations = envVarService.GetListEnvironmentVariable(DevConfigurationsEnvVar) ?? [];
this.Logger.LogDebug("Gradle dev-only lockfiles {Lockfiles}", string.Join(", ", this.devLockfiles));
this.Logger.LogDebug("Gradle dev-only configurations {Configurations}", string.Join(", ", this.devConfigurations));
}
public override string Id { get; } = "Gradle";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Maven) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Maven)];
- public override IList SearchPatterns { get; } = new List { "*.lockfile" };
+ public override IList SearchPatterns { get; } = ["*.lockfile"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Maven };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Maven];
public override int Version { get; } = 3;
diff --git a/src/Microsoft.ComponentDetection.Detectors/ivy/IvyDetector.cs b/src/Microsoft.ComponentDetection.Detectors/ivy/IvyDetector.cs
index 2ff6f4d1..0e9b8cb7 100644
--- a/src/Microsoft.ComponentDetection.Detectors/ivy/IvyDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/ivy/IvyDetector.cs
@@ -43,7 +43,7 @@ public class IvyDetector : FileComponentDetector, IExperimentalDetector
internal const string AntVersionArgument = "-version";
- internal static readonly string[] AdditionalValidCommands = { "ant" };
+ internal static readonly string[] AdditionalValidCommands = ["ant"];
private readonly ICommandLineInvocationService commandLineInvocationService;
@@ -61,13 +61,13 @@ public class IvyDetector : FileComponentDetector, IExperimentalDetector
public override string Id => "Ivy";
- public override IList SearchPatterns => new List { "ivy.xml" };
+ public override IList SearchPatterns => ["ivy.xml"];
- public override IEnumerable SupportedComponentTypes => new[] { ComponentType.Maven };
+ public override IEnumerable SupportedComponentTypes => [ComponentType.Maven];
public override int Version => 2;
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Maven) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Maven)];
protected override async Task> OnPrepareDetectionAsync(
IObservable processRequests,
diff --git a/src/Microsoft.ComponentDetection.Detectors/linux/Exceptions/MissingContainerDetailException.cs b/src/Microsoft.ComponentDetection.Detectors/linux/Exceptions/MissingContainerDetailException.cs
index 8f820cf1..0b85170a 100644
--- a/src/Microsoft.ComponentDetection.Detectors/linux/Exceptions/MissingContainerDetailException.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/linux/Exceptions/MissingContainerDetailException.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.Linux.Exceptions;
+namespace Microsoft.ComponentDetection.Detectors.Linux.Exceptions;
using System;
diff --git a/src/Microsoft.ComponentDetection.Detectors/linux/ILinuxScanner.cs b/src/Microsoft.ComponentDetection.Detectors/linux/ILinuxScanner.cs
index 2defc6f4..5b3e3ef9 100644
--- a/src/Microsoft.ComponentDetection.Detectors/linux/ILinuxScanner.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/linux/ILinuxScanner.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.Linux;
+namespace Microsoft.ComponentDetection.Detectors.Linux;
using System.Collections.Generic;
using System.Threading;
diff --git a/src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs b/src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs
index 9dabf30c..fcd655ba 100644
--- a/src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs
@@ -31,9 +31,9 @@ public class LinuxContainerDetector : IComponentDetector
public string Id => "Linux";
- public IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Linux) };
+ public IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Linux)];
- public IEnumerable SupportedComponentTypes => new[] { ComponentType.Linux };
+ public IEnumerable SupportedComponentTypes => [ComponentType.Linux];
public int Version => 4;
@@ -47,7 +47,7 @@ public class LinuxContainerDetector : IComponentDetector
.ToList();
#pragma warning restore CA1308
- if (imagesToProcess == null || !imagesToProcess.Any())
+ if (imagesToProcess == null || imagesToProcess.Count == 0)
{
this.logger.LogInformation("No instructions received to scan docker images.");
return EmptySuccessfulScan();
@@ -110,7 +110,7 @@ public class LinuxContainerDetector : IComponentDetector
return new ImageScanningResult
{
ContainerDetails = null,
- Components = Enumerable.Empty(),
+ Components = [],
};
}
@@ -135,13 +135,7 @@ public class LinuxContainerDetector : IComponentDetector
null);
}
- var imageDetails = await this.dockerService.InspectImageAsync(image, cancellationToken);
-
- // Unable to fetch image details
- if (imageDetails == null)
- {
- throw new MissingContainerDetailException(image);
- }
+ var imageDetails = await this.dockerService.InspectImageAsync(image, cancellationToken) ?? throw new MissingContainerDetailException(image);
processedImages.TryAdd(imageDetails.ImageId, imageDetails);
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/linux/LinuxScanner.cs b/src/Microsoft.ComponentDetection.Detectors/linux/LinuxScanner.cs
index 84fca195..e49cfc03 100644
--- a/src/Microsoft.ComponentDetection.Detectors/linux/LinuxScanner.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/linux/LinuxScanner.cs
@@ -17,12 +17,16 @@ public class LinuxScanner : ILinuxScanner
{
private const string ScannerImage = "governancecontainerregistry.azurecr.io/syft:v0.100.0@sha256:df7b07bfadff45e0135d74f22478f47b16ac6aff4e8dbd93133fcae3bbbb790d";
- private static readonly IList CmdParameters = new List
- {
- "--quiet", "--scope", "all-layers", "--output", "json",
- };
+ private static readonly IList CmdParameters =
+ [
+ "--quiet",
+ "--scope",
+ "all-layers",
+ "--output",
+ "json",
+ ];
- private static readonly IEnumerable AllowedArtifactTypes = new[] { "apk", "deb", "rpm" };
+ private static readonly IEnumerable AllowedArtifactTypes = ["apk", "deb", "rpm"];
private static readonly SemaphoreSlim DockerSemaphore = new SemaphoreSlim(2);
@@ -163,7 +167,7 @@ public class LinuxScanner : ILinuxScanner
}
var licenses = artifact.Licenses;
- if (licenses != null && licenses.Any())
+ if (licenses != null && licenses.Length != 0)
{
return string.Join(", ", licenses.Select(l => l.Value));
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/maven/GraphNode.cs b/src/Microsoft.ComponentDetection.Detectors/maven/GraphNode.cs
index faf14864..0355d203 100644
--- a/src/Microsoft.ComponentDetection.Detectors/maven/GraphNode.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/maven/GraphNode.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.Maven;
+namespace Microsoft.ComponentDetection.Detectors.Maven;
using System.Collections.Generic;
@@ -12,7 +12,7 @@ public class GraphNode
public T Value { get; set; }
- public List> Children { get; } = new List>();
+ public List> Children { get; } = [];
- public List> Parents { get; } = new List>();
+ public List> Parents { get; } = [];
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/maven/MavenCommandService.cs b/src/Microsoft.ComponentDetection.Detectors/maven/MavenCommandService.cs
index b36bb53a..6d075656 100644
--- a/src/Microsoft.ComponentDetection.Detectors/maven/MavenCommandService.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/maven/MavenCommandService.cs
@@ -16,7 +16,7 @@ public class MavenCommandService : IMavenCommandService
internal const string MvnVersionArgument = "--version";
- internal static readonly string[] AdditionalValidCommands = new[] { "mvn.cmd" };
+ internal static readonly string[] AdditionalValidCommands = ["mvn.cmd"];
private readonly ICommandLineInvocationService commandLineInvocationService;
private readonly IMavenStyleDependencyGraphParserService parserService;
diff --git a/src/Microsoft.ComponentDetection.Detectors/maven/MavenParsingUtilities.cs b/src/Microsoft.ComponentDetection.Detectors/maven/MavenParsingUtilities.cs
index 1517a70f..cd4127fa 100644
--- a/src/Microsoft.ComponentDetection.Detectors/maven/MavenParsingUtilities.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/maven/MavenParsingUtilities.cs
@@ -47,7 +47,7 @@ public static class MavenParsingUtilities
{
// Six part versions have an entry in their 4th index. We remove it to normalize. E.g.:
// var mysteriousSixPartVersionPart = results[3];
- results = new[] { results[0], results[1], results[2], results[4], results[5] };
+ results = [results[0], results[1], results[2], results[4], results[5]];
}
// 'MavenCompile' is a default scope for maven dependencies.
diff --git a/src/Microsoft.ComponentDetection.Detectors/maven/MavenStyleDependencyGraphParser.cs b/src/Microsoft.ComponentDetection.Detectors/maven/MavenStyleDependencyGraphParser.cs
index 3598bece..3883e03d 100644
--- a/src/Microsoft.ComponentDetection.Detectors/maven/MavenStyleDependencyGraphParser.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/maven/MavenStyleDependencyGraphParser.cs
@@ -8,9 +8,9 @@ using Microsoft.Extensions.Logging;
public class MavenStyleDependencyGraphParser
{
- private static readonly char[] TrimCharacters = new char[] { '|', ' ' };
+ private static readonly char[] TrimCharacters = ['|', ' '];
- private static readonly string[] ComponentSplitters = new[] { "+-", "\\-" };
+ private static readonly string[] ComponentSplitters = ["+-", "\\-"];
private readonly Stack> stack = new Stack>();
diff --git a/src/Microsoft.ComponentDetection.Detectors/maven/MvnCliComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/maven/MvnCliComponentDetector.cs
index 93195c3e..871f9c7e 100644
--- a/src/Microsoft.ComponentDetection.Detectors/maven/MvnCliComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/maven/MvnCliComponentDetector.cs
@@ -36,13 +36,13 @@ public class MvnCliComponentDetector : FileComponentDetector
public override string Id => "MvnCli";
- public override IList SearchPatterns => new List { MavenManifest };
+ public override IList SearchPatterns => [MavenManifest];
- public override IEnumerable SupportedComponentTypes => new[] { ComponentType.Maven };
+ public override IEnumerable SupportedComponentTypes => [ComponentType.Maven];
public override int Version => 4;
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Maven) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Maven)];
private void LogDebugWithId(string message)
{
@@ -70,7 +70,7 @@ public class MvnCliComponentDetector : FileComponentDetector
this.LogDebugWithId($"Nested {MavenManifest} files processed successfully, retrieving generated dependency graphs.");
- return this.ComponentStreamEnumerableFactory.GetComponentStreams(this.CurrentScanRequest.SourceDirectory, new[] { this.mavenCommandService.BcdeMvnDependencyFileName }, this.CurrentScanRequest.DirectoryExclusionPredicate)
+ return this.ComponentStreamEnumerableFactory.GetComponentStreams(this.CurrentScanRequest.SourceDirectory, [this.mavenCommandService.BcdeMvnDependencyFileName], this.CurrentScanRequest.DirectoryExclusionPredicate)
.Select(componentStream =>
{
// The file stream is going to be disposed after the iteration is finished
@@ -137,7 +137,7 @@ public class MvnCliComponentDetector : FileComponentDetector
var current = directoryItemFacades.GetOrAdd(currentDir, _ => new DirectoryItemFacadeOptimized
{
Name = currentDir,
- FileNames = new HashSet(),
+ FileNames = [],
});
// If we didn't come from a directory, it's because we're just getting started. Our current directory should include the file that led to it showing up in the graph.
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1.cs b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1.cs
index ac4139ba..f519629f 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1.cs
@@ -1,4 +1,4 @@
-#nullable enable
+#nullable enable
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1Dependency.cs b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1Dependency.cs
index b06259d3..92c47e71 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1Dependency.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV1Dependency.cs
@@ -1,4 +1,4 @@
-#nullable enable
+#nullable enable
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2.cs b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2.cs
index 45652bda..bef57a87 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2.cs
@@ -1,4 +1,4 @@
-#nullable enable
+#nullable enable
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Dependency.cs b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Dependency.cs
index fe5ce5eb..f0522ef2 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Dependency.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Dependency.cs
@@ -1,4 +1,4 @@
-#nullable enable
+#nullable enable
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Package.cs b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Package.cs
index ccb308f0..d668f0b3 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Package.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV2Package.cs
@@ -1,4 +1,4 @@
-#nullable enable
+#nullable enable
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3.cs b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3.cs
index 27d7b924..714f1920 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3.cs
@@ -1,4 +1,4 @@
-#nullable enable
+#nullable enable
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3Package.cs b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3Package.cs
index f56bc5fd..274e169d 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3Package.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/Contracts/PackageLockV3Package.cs
@@ -1,4 +1,4 @@
-#nullable enable
+#nullable enable
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
using System.Collections.Generic;
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentDetector.cs
index dc4c643f..1ed41a72 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentDetector.cs
@@ -34,11 +34,11 @@ public class NpmComponentDetector : FileComponentDetector
public override string Id { get; } = "Npm";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Npm) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Npm)];
- public override IList SearchPatterns { get; } = new List { "package.json" };
+ public override IList SearchPatterns { get; } = ["package.json"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Npm };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Npm];
public override int Version { get; } = 2;
@@ -52,7 +52,7 @@ public class NpmComponentDetector : FileComponentDetector
string contents;
using (var reader = new StreamReader(file.Stream))
{
- contents = await reader.ReadToEndAsync();
+ contents = await reader.ReadToEndAsync(cancellationToken);
}
await this.SafeProcessAllPackageJTokensAsync(filePath, contents, (token) =>
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentUtilities.cs b/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentUtilities.cs
index 1f3859f2..b65c108c 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentUtilities.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentUtilities.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.Npm;
+namespace Microsoft.ComponentDetection.Detectors.Npm;
using System;
using System.Collections.Generic;
@@ -95,7 +95,7 @@ public static class NpmComponentUtilities
public static IDictionary> TryGetAllPackageJsonDependencies(Stream stream, out IList yarnWorkspaces)
{
- yarnWorkspaces = new List();
+ yarnWorkspaces = [];
using var file = new StreamReader(stream);
using var reader = new JsonTextReader(file);
diff --git a/src/Microsoft.ComponentDetection.Detectors/npm/NpmLockfileDetectorBase.cs b/src/Microsoft.ComponentDetection.Detectors/npm/NpmLockfileDetectorBase.cs
index 5e7ea264..39026ad7 100644
--- a/src/Microsoft.ComponentDetection.Detectors/npm/NpmLockfileDetectorBase.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/npm/NpmLockfileDetectorBase.cs
@@ -47,16 +47,16 @@ public abstract class NpmLockfileDetectorBase : FileComponentDetector
/// Used in scenarios where one file path creates multiple JTokens, a false value indicates processing additional JTokens should be halted, proceed otherwise.
protected delegate bool JTokenProcessingDelegate(JToken token);
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Npm) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Npm)];
- public override IList SearchPatterns { get; } = new List { "package-lock.json", "npm-shrinkwrap.json", LernaSearchPattern };
+ public override IList SearchPatterns { get; } = ["package-lock.json", "npm-shrinkwrap.json", LernaSearchPattern];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Npm };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Npm];
- private List LernaFiles { get; } = new();
+ private List LernaFiles { get; } = [];
///
- protected override IList SkippedFolders => new List { "node_modules", "pnpm-store" };
+ protected override IList SkippedFolders => ["node_modules", "pnpm-store"];
protected abstract bool IsSupportedLockfileVersion(int lockfileVersion);
@@ -98,7 +98,7 @@ public abstract class NpmLockfileDetectorBase : FileComponentDetector
protected override async Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary detectorArgs, CancellationToken cancellationToken = default)
{
- IEnumerable packageJsonPattern = new List { "package.json" };
+ IEnumerable packageJsonPattern = ["package.json"];
var singleFileComponentRecorder = processRequest.SingleFileComponentRecorder;
var file = processRequest.ComponentStream;
@@ -243,8 +243,8 @@ public abstract class NpmLockfileDetectorBase : FileComponentDetector
directoryItemFacadesByPath[currentDir] = current = new DirectoryItemFacade
{
Name = currentDir,
- Files = new List(),
- Directories = new List(),
+ Files = [],
+ Directories = [],
};
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs
index e8337040..eba09e5c 100644
--- a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetComponentDetector.cs
@@ -18,11 +18,11 @@ using Microsoft.Extensions.Logging;
public class NuGetComponentDetector : FileComponentDetector
{
- private static readonly IEnumerable LowConfidencePackages = new[] { "Newtonsoft.Json" };
+ private static readonly IEnumerable LowConfidencePackages = ["Newtonsoft.Json"];
public const string NugetConfigFileName = "nuget.config";
- private readonly IList repositoryPathKeyNames = new List { "repositorypath", "globalpackagesfolder" };
+ private readonly IList repositoryPathKeyNames = ["repositorypath", "globalpackagesfolder"];
public NuGetComponentDetector(
IComponentStreamEnumerableFactory componentStreamEnumerableFactory,
@@ -36,11 +36,11 @@ public class NuGetComponentDetector : FileComponentDetector
public override string Id { get; } = "NuGet";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet)];
- public override IList SearchPatterns { get; } = new List { "*.nupkg", "*.nuspec", NugetConfigFileName, "paket.lock" };
+ public override IList SearchPatterns { get; } = ["*.nupkg", "*.nuspec", NugetConfigFileName, "paket.lock"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.NuGet };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.NuGet];
public override int Version { get; } = 2;
diff --git a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetNuspecUtilities.cs b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetNuspecUtilities.cs
index b0c054e2..cff3b98b 100644
--- a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetNuspecUtilities.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetNuspecUtilities.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.NuGet;
+namespace Microsoft.ComponentDetection.Detectors.NuGet;
using System;
using System.IO;
@@ -27,20 +27,15 @@ public static class NuGetNuspecUtilities
var nuspecEntry =
archive.Entries.FirstOrDefault(x =>
x.Name.EndsWith(".nuspec", StringComparison.OrdinalIgnoreCase)
- && !x.FullName.Contains('/'));
-
- if (nuspecEntry == null)
- {
- throw new FileNotFoundException("No nuspec file was found");
- }
+ && !x.FullName.Contains('/')) ?? throw new FileNotFoundException("No nuspec file was found");
using var nuspecStream = nuspecEntry.Open();
return await GetNuspecBytesFromNuspecStreamAsync(nuspecStream, nuspecEntry.Length);
}
- catch (InvalidDataException ex)
+ catch (InvalidDataException)
{
- throw ex;
+ throw;
}
finally
{
diff --git a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetPackagesConfigDetector.cs b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetPackagesConfigDetector.cs
index 78101338..44a899c2 100644
--- a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetPackagesConfigDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetPackagesConfigDetector.cs
@@ -33,17 +33,17 @@ public sealed class NuGetPackagesConfigDetector : FileComponentDetector
}
///
- public override IList SearchPatterns => new[] { "packages.config" };
+ public override IList SearchPatterns => ["packages.config"];
///
public override string Id => "NuGetPackagesConfig";
///
public override IEnumerable Categories =>
- new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet) };
+ [Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet)];
///
- public override IEnumerable SupportedComponentTypes => new[] { ComponentType.NuGet };
+ public override IEnumerable SupportedComponentTypes => [ComponentType.NuGet];
///
public override int Version => 1;
diff --git a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetProjectModelProjectCentricComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetProjectModelProjectCentricComponentDetector.cs
index 33232d87..162f1b3d 100644
--- a/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetProjectModelProjectCentricComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/nuget/NuGetProjectModelProjectCentricComponentDetector.cs
@@ -24,13 +24,13 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
private readonly ConcurrentDictionary frameworkComponentsThatWereOmmittedWithCount = new ConcurrentDictionary();
- private readonly List netCoreFrameworkNames = new List { "Microsoft.AspNetCore.App", "Microsoft.AspNetCore.Razor.Design", "Microsoft.NETCore.App" };
+ private readonly List netCoreFrameworkNames = ["Microsoft.AspNetCore.App", "Microsoft.AspNetCore.Razor.Design", "Microsoft.NETCore.App"];
// This list is meant to encompass all net standard dependencies, but likely contains some net core app 1.x ones, too.
// The specific guidance we got around populating this list is to do so based on creating a dotnet core 1.x app to make sure we had the complete
// set of netstandard.library files that could show up in later sdk versions.
- private readonly string[] netStandardDependencies = new[]
- {
+ private readonly string[] netStandardDependencies =
+ [
"Libuv",
"Microsoft.CodeAnalysis.Analyzers",
"Microsoft.CodeAnalysis.Common",
@@ -183,7 +183,7 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
"System.Xml.XmlSerializer",
"System.Xml.XPath",
"System.Xml.XPath.XDocument",
- };
+ ];
private readonly IFileUtilityService fileUtilityService;
@@ -201,11 +201,11 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
public override string Id { get; } = "NuGetProjectCentric";
- public override IEnumerable Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet) };
+ public override IEnumerable Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet)];
- public override IList SearchPatterns { get; } = new List { "project.assets.json" };
+ public override IList SearchPatterns { get; } = ["project.assets.json"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.NuGet };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.NuGet];
public override int Version { get; } = 1;
@@ -273,7 +273,7 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
return;
}
- visited ??= new HashSet();
+ visited ??= [];
var libraryComponent = new DetectedComponent(new NuGetComponent(library.Name, library.Version.ToNormalizedString()));
singleFileComponentRecorder.RegisterUsage(libraryComponent, explicitlyReferencedComponentIds.Contains(libraryComponent.Component.Id), parentComponentId);
@@ -427,7 +427,7 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
private HashSet GetDependencyComponentIds(LockFile lockFile, LockFileTarget target, IList dependencies, HashSet visited = null)
{
- visited ??= new HashSet();
+ visited ??= [];
var currentComponents = new HashSet();
foreach (var dependency in dependencies)
{
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/IPythonResolver.cs b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/IPythonResolver.cs
index 8a34b4bc..a1a3a62b 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/IPythonResolver.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/IPythonResolver.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.Pip;
+namespace Microsoft.ComponentDetection.Detectors.Pip;
using System.Collections.Generic;
using System.Threading.Tasks;
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipDependencySpecification.cs b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipDependencySpecification.cs
index c0d3b08a..e1093cb5 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipDependencySpecification.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipDependencySpecification.cs
@@ -26,8 +26,8 @@ public class PipDependencySpecification
///
/// These are packages that we don't want to evaluate in our graph as they are generally python builtins.
///
- public static readonly HashSet PackagesToIgnore = new HashSet
- {
+ public static readonly HashSet PackagesToIgnore =
+ [
"-markerlib",
"pip",
"pip-tools",
@@ -35,7 +35,7 @@ public class PipDependencySpecification
"pkg-resources",
"setuptools",
"wheel",
- };
+ ];
// Extracts abcd from a string like abcd==1.*,!=1.3
private static readonly Regex PipNameExtractionRegex = new Regex(
@@ -82,9 +82,9 @@ public class PipDependencySpecification
///
/// Gets or sets the set of dependency specifications that constrain the overall dependency request (ex: ==1.0, >=2.0).
///
- public IList DependencySpecifiers { get; set; } = new List();
+ public IList DependencySpecifiers { get; set; } = [];
- public IList ConditionalDependencySpecifiers { get; set; } = new List();
+ public IList ConditionalDependencySpecifiers { get; set; } = [];
private string DebuggerDisplay => $"{this.Name} ({string.Join(';', this.DependencySpecifiers)})";
@@ -186,15 +186,12 @@ public class PipDependencySpecification
var conditionalSpec = $"{conditionalOperator}{conditionalValue}";
try
{
- conditionMet = PythonVersionUtilities.VersionValidForSpec(pythonEnvironmentVariables[conditionalVar], new List { conditionalSpec });
+ conditionMet = PythonVersionUtilities.VersionValidForSpec(pythonEnvironmentVariables[conditionalVar], [conditionalSpec]);
}
catch (ArgumentException ae)
{
conditionMet = false;
- if (this.Logger != null)
- {
- this.Logger.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
- }
+ this.Logger?.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
}
}
else
@@ -256,10 +253,7 @@ public class PipDependencySpecification
}
catch (ArgumentException ae)
{
- if (this.Logger != null)
- {
- this.Logger.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
- }
+ this.Logger?.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
return null;
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipGraphNode.cs b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipGraphNode.cs
index 15f7383f..c08576ad 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipGraphNode.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipGraphNode.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.Pip;
+namespace Microsoft.ComponentDetection.Detectors.Pip;
using System.Collections.Generic;
using Microsoft.ComponentDetection.Contracts.TypedComponent;
@@ -13,7 +13,7 @@ public class PipGraphNode
public PipComponent Value { get; set; }
- public List Children { get; } = new List();
+ public List Children { get; } = [];
- public List Parents { get; } = new List();
+ public List Parents { get; } = [];
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipReportGraphNode.cs b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipReportGraphNode.cs
index 8b689000..690e4426 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipReportGraphNode.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PipReportGraphNode.cs
@@ -17,9 +17,9 @@ public sealed record PipReportGraphNode
public PipComponent Value { get; set; }
- public List Children { get; } = new List();
+ public List Children { get; } = [];
- public List Parents { get; } = new List();
+ public List Parents { get; } = [];
public bool Requested { get; set; }
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonResolverState.cs b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonResolverState.cs
index 0f0ea516..adae76e7 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonResolverState.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonResolverState.cs
@@ -12,5 +12,5 @@ public class PythonResolverState
public IDictionary NodeReferences { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase);
- public IList Roots { get; } = new List();
+ public IList Roots { get; } = [];
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonVersion.cs b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonVersion.cs
index a16fbdb0..8564a6f9 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonVersion.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/Contracts/PythonVersion.cs
@@ -111,10 +111,7 @@ public class PythonVersion : IComparable
public static PythonVersion Create(string version)
{
- if (version == null)
- {
- throw new ArgumentNullException(nameof(version));
- }
+ ArgumentNullException.ThrowIfNull(version);
if (Cache.TryGetValue(version, out var cachedVersion))
{
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/PipComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/pip/PipComponentDetector.cs
index f50175c0..46cc33de 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/PipComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/PipComponentDetector.cs
@@ -32,11 +32,11 @@ public class PipComponentDetector : FileComponentDetector, IDefaultOffComponentD
public override string Id => "Pip";
- public override IList SearchPatterns => new List { "setup.py", "requirements.txt" };
+ public override IList SearchPatterns => ["setup.py", "requirements.txt"];
- public override IEnumerable Categories => new List { "Python" };
+ public override IEnumerable Categories => ["Python"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Pip };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Pip];
public override int Version { get; } = 13;
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/PipReportComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/pip/PipReportComponentDetector.cs
index 0a24d9fa..9e8d01c5 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/PipReportComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/PipReportComponentDetector.cs
@@ -24,7 +24,7 @@ public class PipReportComponentDetector : FileComponentDetector
private const string PipReportFileLevelTimeoutSecondsEnvVar = "PipReportFileLevelTimeoutSeconds";
private const string PipReportPersistReportsEnvVar = "PipReportPersistReports";
- private static readonly IList PipReportPreGeneratedFilePatterns = new List { "*.component-detection-pip-report.json", "component-detection-pip-report.json" };
+ private static readonly IList PipReportPreGeneratedFilePatterns = ["*.component-detection-pip-report.json", "component-detection-pip-report.json"];
///
/// The maximum version of the report specification that this detector can handle.
@@ -71,11 +71,11 @@ public class PipReportComponentDetector : FileComponentDetector
public override string Id => "PipReport";
- public override IList SearchPatterns => new List { "setup.py", "requirements.txt" };
+ public override IList SearchPatterns => ["setup.py", "requirements.txt"];
- public override IEnumerable Categories => new List { "Python" };
+ public override IEnumerable Categories => ["Python"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Pip };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Pip];
public override int Version { get; } = 8;
@@ -127,7 +127,7 @@ public class PipReportComponentDetector : FileComponentDetector
var singleFileComponentRecorder = processRequest.SingleFileComponentRecorder;
var file = processRequest.ComponentStream;
- List reportFiles = new();
+ List reportFiles = [];
try
{
var pipOverride = this.GetPipReportOverrideBehavior();
@@ -186,8 +186,8 @@ public class PipReportComponentDetector : FileComponentDetector
.ToList();
}
- List reports = new();
- if (preGeneratedReportFiles is not null && preGeneratedReportFiles.Any())
+ List reports = [];
+ if (preGeneratedReportFiles is not null && preGeneratedReportFiles.Count != 0)
{
this.Logger.LogInformation("PipReport: Found pre-generated pip report(s) for {File}.", file.Location);
@@ -211,7 +211,7 @@ public class PipReportComponentDetector : FileComponentDetector
}
}
- var foundPreGeneratedReport = reports.Any();
+ var foundPreGeneratedReport = reports.Count != 0;
pipReportTypeRecord.PreGenerated = foundPreGeneratedReport;
if (!foundPreGeneratedReport)
{
@@ -233,7 +233,7 @@ public class PipReportComponentDetector : FileComponentDetector
reportFiles.Add(reportFile);
}
- if (!reports.Any())
+ if (reports.Count == 0)
{
this.Logger.LogWarning("PipReport: Failed to generate or find pip installation report for {File}.", file.Location);
return;
@@ -388,7 +388,7 @@ public class PipReportComponentDetector : FileComponentDetector
}
else
{
- dependenciesByPkg.Add(normalizedPkgName, new List { dependencySpec });
+ dependenciesByPkg.Add(normalizedPkgName, [dependencySpec]);
}
}
}
@@ -440,7 +440,7 @@ public class PipReportComponentDetector : FileComponentDetector
// parentComponentId is guaranteed to exist in the graph or an exception will be thrown.
foreach (var node in graph.Values)
{
- if (!node.Parents.Any())
+ if (node.Parents.Count == 0)
{
continue;
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/PythonCommandService.cs b/src/Microsoft.ComponentDetection.Detectors/pip/PythonCommandService.cs
index 26ce6979..8e0890ed 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/PythonCommandService.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/PythonCommandService.cs
@@ -81,7 +81,7 @@ public class PythonCommandService : IPythonCommandService
if (command.ExitCode != 0)
{
this.logger.LogDebug("Python: Failed distutils setup with error: {StdErr}", command.StdErr);
- return new List();
+ return [];
}
var result = command.StdOut;
@@ -91,7 +91,7 @@ public class PythonCommandService : IPythonCommandService
// For Python2 if there are no packages (Result: "None") skip any parsing
if (result.Equals("None", StringComparison.OrdinalIgnoreCase) && !command.StdOut.StartsWith('['))
{
- return new List();
+ return [];
}
return result.Split(new string[] { "'," }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim().Trim('\'').Trim()).ToList();
@@ -102,7 +102,7 @@ public class PythonCommandService : IPythonCommandService
var items = new List<(string, GitComponent)>();
foreach (var line in File.ReadAllLines(path)
.Select(x => x.Trim().TrimEnd('\\'))
- .Where(x => !x.StartsWith("#") && !x.StartsWith("-") && !string.IsNullOrWhiteSpace(x)))
+ .Where(x => !x.StartsWith('#') && !x.StartsWith('-') && !string.IsNullOrWhiteSpace(x)))
{
// We technically shouldn't be ignoring information after the ;
// It's used to indicate environment markers like specific python versions
@@ -170,13 +170,13 @@ public class PythonCommandService : IPythonCommandService
private async Task CanCommandBeLocatedAsync(string pythonPath)
{
- return await this.commandLineInvocationService.CanCommandBeLocatedAsync(pythonPath, new List { "python3", "python2" }, "--version");
+ return await this.commandLineInvocationService.CanCommandBeLocatedAsync(pythonPath, ["python3", "python2"], "--version");
}
public async Task GetPythonVersionAsync(string pythonPath)
{
var pythonCommand = await this.ResolvePythonAsync(pythonPath);
- var versionResult = await this.commandLineInvocationService.ExecuteCommandAsync(pythonCommand, new List { "python3", "python2" }, "--version");
+ var versionResult = await this.commandLineInvocationService.ExecuteCommandAsync(pythonCommand, ["python3", "python2"], "--version");
var version = new Regex("Python ([\\d.]+)");
var match = version.Match(versionResult.StdOut);
return match.Success ? match.Groups[1].Value : null;
@@ -185,7 +185,7 @@ public class PythonCommandService : IPythonCommandService
public async Task GetOsTypeAsync(string pythonPath)
{
var pythonCommand = await this.ResolvePythonAsync(pythonPath);
- var versionResult = await this.commandLineInvocationService.ExecuteCommandAsync(pythonCommand, new List { "python3", "python2" }, "-c", "\"import sys; print(sys.platform);\"");
+ var versionResult = await this.commandLineInvocationService.ExecuteCommandAsync(pythonCommand, ["python3", "python2"], "-c", "\"import sys; print(sys.platform);\"");
return versionResult.ExitCode == 0 && string.IsNullOrEmpty(versionResult.StdErr) ? versionResult.StdOut.Trim() : null;
}
}
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/PythonNotFoundException.cs b/src/Microsoft.ComponentDetection.Detectors/pip/PythonNotFoundException.cs
index f9fc313c..1f1aa0ed 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/PythonNotFoundException.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/PythonNotFoundException.cs
@@ -1,4 +1,4 @@
-namespace Microsoft.ComponentDetection.Detectors.Pip;
+namespace Microsoft.ComponentDetection.Detectors.Pip;
using System;
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolver.cs b/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolver.cs
index 7154cab4..22535544 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolver.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolver.cs
@@ -14,7 +14,7 @@ public class PythonResolver : PythonResolverBase, IPythonResolver
{
private readonly IPyPiClient pypiClient;
private readonly ILogger logger;
- private readonly Dictionary pythonEnvironmentVariables = new Dictionary();
+ private readonly Dictionary pythonEnvironmentVariables = [];
private readonly int maxLicenseFieldLength = 100;
private readonly string classifierFieldSeparator = " :: ";
@@ -47,12 +47,12 @@ public class PythonResolver : PythonResolverBase, IPythonResolver
var result = project.Releases;
- if (result is not null && result.Keys.Any())
+ if (result is not null && result.Keys.Count != 0)
{
state.ValidVersionMap[rootPackage.Name] = result;
// Grab the latest version as our candidate version
- var candidateVersion = state.ValidVersionMap[rootPackage.Name].Keys.Any()
+ var candidateVersion = state.ValidVersionMap[rootPackage.Name].Keys.Count != 0
? state.ValidVersionMap[rootPackage.Name].Keys.Last() : null;
var node = new PipGraphNode(new PipComponent(rootPackage.Name, candidateVersion, license: this.GetLicenseFromProject(project), author: this.GetSupplierFromProject(project)));
@@ -75,7 +75,7 @@ public class PythonResolver : PythonResolverBase, IPythonResolver
}
// Now queue packages for processing
- return await this.ProcessQueueAsync(singleFileComponentRecorder, state) ?? new List();
+ return await this.ProcessQueueAsync(singleFileComponentRecorder, state) ?? [];
}
private async Task> ProcessQueueAsync(ISingleFileComponentRecorder singleFileComponentRecorder, PythonResolverState state)
@@ -120,10 +120,10 @@ public class PythonResolver : PythonResolverBase, IPythonResolver
var result = project.Releases;
- if (result is not null && result.Keys.Any())
+ if (result is not null && result.Keys.Count != 0)
{
state.ValidVersionMap[dependencyNode.Name] = result;
- var candidateVersion = state.ValidVersionMap[dependencyNode.Name].Keys.Any()
+ var candidateVersion = state.ValidVersionMap[dependencyNode.Name].Keys.Count != 0
? state.ValidVersionMap[dependencyNode.Name].Keys.Last() : null;
this.AddGraphNode(state, state.NodeReferences[currentNode.Name], dependencyNode.Name, candidateVersion, license: this.GetLicenseFromProject(project), author: this.GetSupplierFromProject(project));
@@ -163,7 +163,7 @@ public class PythonResolver : PythonResolverBase, IPythonResolver
state.ValidVersionMap[spec.Name][candidateVersion].FirstOrDefault(x => string.Equals("bdist_egg", x.PackageType, StringComparison.OrdinalIgnoreCase));
if (packageToFetch == null)
{
- return new List();
+ return [];
}
return await this.pypiClient.FetchPackageDependenciesAsync(spec.Name, candidateVersion, packageToFetch);
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolverBase.cs b/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolverBase.cs
index e501d8ff..efc5aa5e 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolverBase.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/PythonResolverBase.cs
@@ -42,7 +42,7 @@ public abstract class PythonResolverBase
return false;
}
- var candidateVersion = state.ValidVersionMap[pipComponent.Name].Keys.Any() ? state.ValidVersionMap[pipComponent.Name].Keys.Last() : null;
+ var candidateVersion = state.ValidVersionMap[pipComponent.Name].Keys.Count != 0 ? state.ValidVersionMap[pipComponent.Name].Keys.Last() : null;
node.Value = new PipComponent(pipComponent.Name, candidateVersion, author: pipComponent.Author, license: pipComponent.License);
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/SimplePipComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/pip/SimplePipComponentDetector.cs
index 47baf7f2..0d697ced 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/SimplePipComponentDetector.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/SimplePipComponentDetector.cs
@@ -32,11 +32,11 @@ public class SimplePipComponentDetector : FileComponentDetector, IDefaultOffComp
public override string Id => "SimplePip";
- public override IList SearchPatterns => new List { "setup.py", "requirements.txt" };
+ public override IList SearchPatterns => ["setup.py", "requirements.txt"];
- public override IEnumerable Categories => new List { "Python" };
+ public override IEnumerable Categories => ["Python"];
- public override IEnumerable SupportedComponentTypes { get; } = new[] { ComponentType.Pip };
+ public override IEnumerable SupportedComponentTypes { get; } = [ComponentType.Pip];
public override int Version { get; } = 3;
diff --git a/src/Microsoft.ComponentDetection.Detectors/pip/SimplePythonResolver.cs b/src/Microsoft.ComponentDetection.Detectors/pip/SimplePythonResolver.cs
index d013b47e..5cda7b22 100644
--- a/src/Microsoft.ComponentDetection.Detectors/pip/SimplePythonResolver.cs
+++ b/src/Microsoft.ComponentDetection.Detectors/pip/SimplePythonResolver.cs
@@ -118,12 +118,12 @@ public class SimplePythonResolver : PythonResolverBase, ISimplePythonResolver
{
var pythonProject = this.ConvertSimplePypiProjectToSortedDictionary(simplePythonProject, rootPackage);
- if (pythonProject.Keys.Any())
+ if (pythonProject.Keys.Count != 0)
{
state.ValidVersionMap[rootPackage.Name] = pythonProject;
// Grab the latest version as our candidate version
- var candidateVersion = state.ValidVersionMap[rootPackage.Name].Keys.Any()
+ var candidateVersion = state.ValidVersionMap[rootPackage.Name].Keys.Count != 0
? state.ValidVersionMap[rootPackage.Name].Keys.Last()
: null;
@@ -147,7 +147,7 @@ public class SimplePythonResolver : PythonResolverBase, ISimplePythonResolver
});
// Now queue packages for processing
- return await this.ProcessQueueAsync(singleFileComponentRecorder, state) ?? new List();
+ return await this.ProcessQueueAsync(singleFileComponentRecorder, state) ?? [];
}
private async Task