Skip to content

Commit 8a744bf

Browse files
authored
Revert to treating PackageDownload as Development Dependency (#1320)
* Revert to treating PackageDownload as Development Dependency
1 parent e7239ea commit 8a744bf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Microsoft.ComponentDetection.Detectors/nuget/NuGetPackageReferenceFrameworkAwareDetector.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,12 @@ private void RegisterPackageDownloads(ISingleFileComponentRecorder singleFileCom
192192

193193
var libraryComponent = new DetectedComponent(new NuGetComponent(packageDownload.Name, packageDownload.VersionRange.MinVersion.ToNormalizedString()));
194194

195-
// Conservatively assume that PackageDownloads are not develeopment dependencies even though usage will not effect any runtime behavior.
196-
// Most often they are used for some runtime deployment -- runtime packs, host packs, AOT infrastructure, etc, so opt in treating them as non-development-dependencies.
195+
// PackageDownload is always a development dependency since it's usage does not make it part of the application
197196
singleFileComponentRecorder.RegisterUsage(
198197
libraryComponent,
199198
isExplicitReferencedDependency: true,
200199
parentComponentId: null,
201-
isDevelopmentDependency: false,
200+
isDevelopmentDependency: true,
202201
targetFramework: framework.FrameworkName?.GetShortFolderName());
203202
}
204203
}

test/Microsoft.ComponentDetection.Detectors.Tests/nuget/NuGetPackageReferenceFrameworkAwareDetectorTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public async Task ScanDirectoryAsync_ExcludedFrameworkComponent_8_0_web_Verifica
276276
.ExecuteDetectorAsync();
277277

278278
var detectedComponents = componentRecorder.GetDetectedComponents();
279-
detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).GetValueOrDefault(), "All should be development dependencies");
279+
detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).Should().BeTrue(), "All should be development dependencies");
280280
}
281281

282282
[TestMethod]
@@ -289,7 +289,7 @@ public async Task ScanDirectoryAsync_ExcludedFrameworkComponent_42_15_web_Verifi
289289

290290
// net42.15 is not a known framework, but it can import framework packages from the closest known framework.
291291
var detectedComponents = componentRecorder.GetDetectedComponents();
292-
detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).GetValueOrDefault(), "All should be development dependencies");
292+
detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).Should().BeTrue(), "All should be development dependencies");
293293
}
294294

295295
[TestMethod]
@@ -329,6 +329,7 @@ public async Task ScanDirectoryAsync_PackageDownload_VerificationAsync()
329329

330330
var dependencies = componentRecorder.GetDetectedComponents();
331331
dependencies.Should().HaveCount(3, "PackageDownload dependencies should exist.");
332+
dependencies.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).Should().BeTrue(), "All PackageDownloads should be development dependencies");
332333
dependencies.Select(c => c.Component).Should().AllBeOfType<NuGetComponent>();
333334
dependencies.Select(c => c.TargetFrameworks).Should().AllSatisfy(tfms => tfms.Should().BeEquivalentTo(["net8.0"]));
334335
}

0 commit comments

Comments
 (0)