Skip to content

Commit 68436c2

Browse files
JamieMageeCopilot
andauthored
refactor: make detector implementation details internal (#1694)
* Make data model/contract classes internal in Detectors project Change public to internal for deserialization model classes that are implementation details across multiple detector ecosystems: conan, pnpm, swiftpm, vcpkg, rust (CargoLock, CargoToml, CargoSbom), poetry, yarn (Berry contracts, TypeConverter), npm (converters), pip (PipReportGraphNode, PythonVersion), and uv model classes. Types exposed through public interfaces/APIs are left public to maintain build compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make detector implementation details internal Make ~80 classes internal in the Detectors project: - Data model/contract classes (ConanLock, PnpmYaml variants, PoetryLock, SwiftResolvedFile, VcpkgSBOM, CargoToml/Sbom, YarnBerry types, npm converters, PipReportGraphNode, PythonVersion, UvLock/Package, etc.) - Parser implementations (GoModParser, YarnLockParser, RustCargoLockParser, MavenStyleDependencyGraphParserService, PnpmParsingUtilities, etc.) - Concrete detector classes (NpmComponentDetector, NuGetComponentDetector, GoComponentDetector, RustSbomDetector, etc.) - Linux scanner internals (LinuxScanner, all component factories, filters) - Service implementations (MavenCommandService, PythonCommandService, PyPiClient, PipCommandService, YarnLockFileFactory, etc.) Kept public (used by downstream consumers): - All interfaces (IComponentDetector, IMavenCommandService, etc.) - MvnCliComponentDetector, MavenWithFallbackDetector (used in is-checks) - PipComponentDetector, SimplePipComponentDetector, PipReportComponentDetector (mocked in tests by component-detection-internal) Updated test classes to work with internal types via InternalsVisibleTo. Part of #455 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0da4e34 commit 68436c2

File tree

121 files changed

+457
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+457
-406
lines changed

src/Microsoft.ComponentDetection.Detectors/Microsoft.ComponentDetection.Detectors.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
<ItemGroup>
44
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Orchestrator" />
5+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Orchestrator.Tests" />
56
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Detectors.Tests" />
67
<InternalsVisibleTo Include="Microsoft.ComponentDetection.TestsUtilities" />
8+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />
79
</ItemGroup>
810

911
<ItemGroup>

src/Microsoft.ComponentDetection.Detectors/cocoapods/PodComponentDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.ComponentDetection.Detectors.CocoaPods;
1616
using YamlDotNet.Core.Events;
1717
using YamlDotNet.Serialization;
1818

19-
public class PodComponentDetector : FileComponentDetector
19+
internal class PodComponentDetector : FileComponentDetector
2020
{
2121
public PodComponentDetector(
2222
IComponentStreamEnumerableFactory componentStreamEnumerableFactory,

src/Microsoft.ComponentDetection.Detectors/conan/ConanLockComponentDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Microsoft.ComponentDetection.Detectors.Conan;
1313
using Microsoft.ComponentDetection.Detectors.Conan.Contracts;
1414
using Microsoft.Extensions.Logging;
1515

16-
public class ConanLockComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
16+
internal class ConanLockComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
1717
{
1818
public ConanLockComponentDetector(
1919
IComponentStreamEnumerableFactory componentStreamEnumerableFactory,

src/Microsoft.ComponentDetection.Detectors/conan/Contracts/ConanLock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Microsoft.ComponentDetection.Detectors.Conan.Contracts;
33

44
using System.Text.Json.Serialization;
55

6-
public class ConanLock
6+
internal class ConanLock
77
{
88
[JsonPropertyName("version")]
99
public string Version { get; set; }

src/Microsoft.ComponentDetection.Detectors/conan/Contracts/ConanLockGraph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Microsoft.ComponentDetection.Detectors.Conan.Contracts;
44
using System.Collections.Generic;
55
using System.Text.Json.Serialization;
66

7-
public class ConanLockGraph
7+
internal class ConanLockGraph
88
{
99
[JsonPropertyName("revisions_enabled")]
1010
public bool RevisionsEnabled { get; set; }

src/Microsoft.ComponentDetection.Detectors/conan/Contracts/ConanLockNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Microsoft.ComponentDetection.Detectors.Conan.Contracts;
66
using System.Text.Json.Serialization;
77
using Microsoft.ComponentDetection.Contracts.TypedComponent;
88

9-
public class ConanLockNode
9+
internal class ConanLockNode
1010
{
1111
[JsonPropertyName("context")]
1212
public string Context { get; set; }

src/Microsoft.ComponentDetection.Detectors/conda/CondaLockComponentDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.ComponentDetection.Detectors.Poetry;
1414
using Microsoft.Extensions.Logging;
1515
using YamlDotNet.Serialization;
1616

17-
public class CondaLockComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
17+
internal class CondaLockComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
1818
{
1919
public CondaLockComponentDetector(
2020
IComponentStreamEnumerableFactory componentStreamEnumerableFactory,

src/Microsoft.ComponentDetection.Detectors/dockerfile/DockerfileComponentDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Microsoft.ComponentDetection.Detectors.Dockerfile;
1515
using Microsoft.Extensions.Logging;
1616
using Valleysoft.DockerfileModel;
1717

18-
public class DockerfileComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
18+
internal class DockerfileComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
1919
{
2020
private readonly ICommandLineInvocationService commandLineInvocationService;
2121
private readonly IEnvironmentVariableService envVarService;

src/Microsoft.ComponentDetection.Detectors/dotnet/DotNetComponentDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.ComponentDetection.Detectors.DotNet;
1616
using Microsoft.ComponentDetection.Contracts.TypedComponent;
1717
using Microsoft.Extensions.Logging;
1818

19-
public class DotNetComponentDetector : FileComponentDetector
19+
internal class DotNetComponentDetector : FileComponentDetector
2020
{
2121
private const string GlobalJsonFileName = "global.json";
2222
private readonly ICommandLineInvocationService commandLineInvocationService;

src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.ComponentDetection.Detectors.Go;
1616
using Microsoft.ComponentDetection.Contracts.TypedComponent;
1717
using Microsoft.Extensions.Logging;
1818

19-
public class GoComponentDetector : FileComponentDetector
19+
internal class GoComponentDetector : FileComponentDetector
2020
{
2121
private readonly HashSet<string> projectRoots = [];
2222

0 commit comments

Comments
 (0)