Skip to content

Commit 0da4e34

Browse files
authored
refactor: standardize InternalsVisibleTo in csproj files (#1690)
Consolidate all [assembly: InternalsVisibleTo] attributes from scattered .cs files into their respective .csproj files using MSBuild items. Add cross-project InternalsVisibleTo entries to enable future phases of making implementation details internal: - Detectors → Orchestrator, Tests, TestsUtilities - Common → Tests, Orchestrator, Detectors, TestsUtilities - Orchestrator → Tests, CLI entry point, TestsUtilities - Contracts → Tests, TestsUtilities Remove scattered attributes from: - ComponentRecorder.cs - DependencyGraph.cs - TelemetryConstants.cs - IPyPiClient.cs Part of #455
1 parent 6782103 commit 0da4e34

File tree

8 files changed

+32
-22
lines changed

8 files changed

+32
-22
lines changed

src/Microsoft.ComponentDetection.Common/DependencyGraph/ComponentRecorder.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#nullable disable
2+
3+
namespace Microsoft.ComponentDetection.Common.DependencyGraph;
4+
25
using System;
36
using System.Collections.Concurrent;
47
using System.Collections.Generic;
58
using System.Collections.Immutable;
9+
using System.Collections.ObjectModel;
610
using System.Linq;
7-
using System.Runtime.CompilerServices;
811
using Microsoft.ComponentDetection.Contracts;
912
using Microsoft.ComponentDetection.Contracts.BcdeModels;
1013
using Microsoft.ComponentDetection.Contracts.TypedComponent;
11-
12-
[assembly: InternalsVisibleTo("Microsoft.ComponentDetection.Common.Tests")]
13-
14-
namespace Microsoft.ComponentDetection.Common.DependencyGraph;
15-
16-
using System.Collections.ObjectModel;
1714
using Microsoft.Extensions.Logging;
1815

1916
public class ComponentRecorder : IComponentRecorder

src/Microsoft.ComponentDetection.Common/DependencyGraph/DependencyGraph.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
#nullable disable
2+
3+
namespace Microsoft.ComponentDetection.Common.DependencyGraph;
4+
25
using System;
36
using System.Collections.Concurrent;
47
using System.Collections.Generic;
58
using System.Collections.Immutable;
69
using System.Linq;
7-
using System.Runtime.CompilerServices;
810
using System.Text;
911
using Microsoft.ComponentDetection.Contracts;
1012
using Microsoft.ComponentDetection.Contracts.BcdeModels;
1113
using Microsoft.ComponentDetection.Contracts.TypedComponent;
1214

13-
[assembly: InternalsVisibleTo("Microsoft.ComponentDetection.Common.Tests")]
14-
15-
namespace Microsoft.ComponentDetection.Common.DependencyGraph;
16-
1715
internal class DependencyGraph : IDependencyGraph
1816
{
1917
private static readonly CompositeFormat MissingNodeFormat = CompositeFormat.Parse(Resources.MissingNodeInDependencyGraph);

src/Microsoft.ComponentDetection.Common/Microsoft.ComponentDetection.Common.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<ItemGroup>
4+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Common.Tests" />
5+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Orchestrator" />
6+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Detectors" />
7+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.TestsUtilities" />
8+
</ItemGroup>
9+
310
<ItemGroup>
411
<PackageReference Include="Docker.DotNet" />
512
<PackageReference Include="Microsoft.Extensions.Logging" />

src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryConstants.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using System;
2-
using System.Runtime.CompilerServices;
3-
4-
[assembly: InternalsVisibleTo("Microsoft.ComponentDetection.Orchestrator")]
5-
61
namespace Microsoft.ComponentDetection.Common.Telemetry;
72

3+
using System;
4+
85
public static class TelemetryConstants
96
{
107
private static Guid correlationId;

src/Microsoft.ComponentDetection.Contracts/Microsoft.ComponentDetection.Contracts.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
<ItemGroup>
88
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Contracts.Tests" />
9+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.TestsUtilities" />
910
</ItemGroup>
1011

1112
<ItemGroup>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<ItemGroup>
4+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Orchestrator" />
5+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Detectors.Tests" />
6+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.TestsUtilities" />
7+
</ItemGroup>
8+
39
<ItemGroup>
410
<PackageReference Include="DotNet.Glob" />
511
<PackageReference Include="Microsoft.Extensions.Logging" />

src/Microsoft.ComponentDetection.Detectors/pip/IPyPiClient.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#nullable disable
2+
3+
namespace Microsoft.ComponentDetection.Detectors.Pip;
4+
25
using System;
36
using System.Collections.Generic;
47
using System.IO;
@@ -7,7 +10,6 @@
710
using System.Net.Http;
811
using System.Net.Http.Headers;
912
using System.Reflection;
10-
using System.Runtime.CompilerServices;
1113
using System.Text.Encodings.Web;
1214
using System.Text.Json;
1315
using System.Threading;
@@ -18,10 +20,6 @@
1820
using Microsoft.Extensions.Logging;
1921
using Polly;
2022

21-
[assembly: InternalsVisibleTo("Microsoft.ComponentDetection.Detectors.Tests")]
22-
23-
namespace Microsoft.ComponentDetection.Detectors.Pip;
24-
2523
public interface IPyPiClient
2624
{
2725
Task<IList<PipDependencySpecification>> FetchPackageDependenciesAsync(string name, string version, PythonProjectRelease release);

src/Microsoft.ComponentDetection.Orchestrator/Microsoft.ComponentDetection.Orchestrator.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<ItemGroup>
4+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.Orchestrator.Tests" />
5+
<InternalsVisibleTo Include="Microsoft.ComponentDetection" />
6+
<InternalsVisibleTo Include="Microsoft.ComponentDetection.TestsUtilities" />
7+
</ItemGroup>
8+
39
<ItemGroup>
410
<PackageReference Include="CommandLineParser" />
511
<PackageReference Include="DotNet.Glob" />

0 commit comments

Comments
 (0)