From fd57712c28e8ec14fc675c548d63908c3ab691a4 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 7 Jul 2026 15:04:00 -0700 Subject: [PATCH] Promote the Conda ComponentDetector to experimental --- docs/detectors/README.md | 2 +- .../conda/CondaLockComponentDetector.cs | 2 +- .../Configs/CondaLockDetectorExperiment.cs | 23 +++++++++++++++++++ .../Extensions/ServiceCollectionExtensions.cs | 1 + .../ComponentDetectorTests.cs | 9 ++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/Microsoft.ComponentDetection.Orchestrator/Experiments/Configs/CondaLockDetectorExperiment.cs diff --git a/docs/detectors/README.md b/docs/detectors/README.md index 6e4bf3c4d..3f9706eee 100644 --- a/docs/detectors/README.md +++ b/docs/detectors/README.md @@ -16,7 +16,7 @@ | Detector | Status | | -------------------------- | ---------- | -| CondaLockComponentDetector | DefaultOff | +| CondaLockComponentDetector | Experimental | - [Docker Compose](dockercompose.md) diff --git a/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs index bb643e741..9bcf0352a 100644 --- a/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs +++ b/src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs @@ -14,7 +14,7 @@ namespace Microsoft.ComponentDetection.Detectors.Poetry; using Microsoft.Extensions.Logging; using YamlDotNet.Serialization; -public class CondaLockComponentDetector : FileComponentDetector, IDefaultOffComponentDetector +public class CondaLockComponentDetector : FileComponentDetector, IExperimentalDetector { public CondaLockComponentDetector( IComponentStreamEnumerableFactory componentStreamEnumerableFactory, diff --git a/src/Microsoft.ComponentDetection.Orchestrator/Experiments/Configs/CondaLockDetectorExperiment.cs b/src/Microsoft.ComponentDetection.Orchestrator/Experiments/Configs/CondaLockDetectorExperiment.cs new file mode 100644 index 000000000..d17f9b4f0 --- /dev/null +++ b/src/Microsoft.ComponentDetection.Orchestrator/Experiments/Configs/CondaLockDetectorExperiment.cs @@ -0,0 +1,23 @@ +namespace Microsoft.ComponentDetection.Orchestrator.Experiments.Configs; + +using Microsoft.ComponentDetection.Contracts; +using Microsoft.ComponentDetection.Detectors.Pip; +using Microsoft.ComponentDetection.Detectors.Poetry; + +/// +/// Experiment to validate CondaLockComponentDetector against PipReportComponentDetector. +/// +public class CondaLockDetectorExperiment : IExperimentConfiguration +{ + /// + public string Name => "CondaLockDetectorExperiment"; + + /// + public bool IsInControlGroup(IComponentDetector componentDetector) => componentDetector is PipReportComponentDetector; + + /// + public bool IsInExperimentGroup(IComponentDetector componentDetector) => componentDetector is CondaLockComponentDetector; + + /// + public bool ShouldRecord(IComponentDetector componentDetector, int numComponents) => true; +} diff --git a/src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs b/src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs index 258955677..48247acff 100644 --- a/src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs +++ b/src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs @@ -73,6 +73,7 @@ public static IServiceCollection AddComponentDetection(this IServiceCollection s services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/test/Microsoft.ComponentDetection.Detectors.Tests/ComponentDetectorTests.cs b/test/Microsoft.ComponentDetection.Detectors.Tests/ComponentDetectorTests.cs index f949cae30..a85fdfd59 100644 --- a/test/Microsoft.ComponentDetection.Detectors.Tests/ComponentDetectorTests.cs +++ b/test/Microsoft.ComponentDetection.Detectors.Tests/ComponentDetectorTests.cs @@ -72,4 +72,13 @@ public void UvLockComponentDetector_ImplementsIExperimentalDetector() uvLockDetector.Should().NotBeNull("because UvLockComponentDetector should be registered"); uvLockDetector.Should().BeAssignableTo("because UvLockComponentDetector should implement IExperimentalDetector"); } + + [TestMethod] + public void CondaLockComponentDetector_ImplementsIExperimentalDetector() + { + var condaLockDetector = this.detectors.SingleOrDefault(d => d.Id == "CondaLock"); + + condaLockDetector.Should().NotBeNull("because CondaLockComponentDetector should be registered"); + condaLockDetector.Should().BeAssignableTo("because CondaLockComponentDetector should implement IExperimentalDetector"); + } }