-
Notifications
You must be signed in to change notification settings - Fork 114
Description
The NPM detectors record components with the following function:
component-detection/src/Microsoft.ComponentDetection.Detectors/npm/NpmComponentUtilities.cs
Lines 30 to 40 in c8c1cc7
| public static DetectedComponent AddOrUpdateDetectedComponent( | |
| ISingleFileComponentRecorder singleFileComponentRecorder, | |
| TypedComponent component, | |
| bool isDevDependency, | |
| string parentComponentId = null, | |
| bool isExplicitReferencedDependency = false) | |
| { | |
| var newComponent = new DetectedComponent(component); | |
| singleFileComponentRecorder.RegisterUsage(newComponent, isExplicitReferencedDependency, parentComponentId, isDevDependency); | |
| return singleFileComponentRecorder.GetComponent(component.Id); | |
| } |
newComponent should have the DevelopmentDependency property set to true, but it is not. However, dev dependencies are still properly registered. When the graph is created, the dev dependency info is propagated:
component-detection/src/Microsoft.ComponentDetection.Common/DependencyGraph/ComponentRecorder.cs
Lines 221 to 238 in c8c1cc7
| private void AddComponentToGraph( | |
| string location, | |
| DetectedComponent detectedComponent, | |
| bool isExplicitReferencedDependency, | |
| string parentComponentId, | |
| bool? isDevelopmentDependency, | |
| DependencyScope? dependencyScope) | |
| { | |
| var componentNode = new DependencyGraph.ComponentRefNode | |
| { | |
| Id = detectedComponent.Component.Id, | |
| IsExplicitReferencedDependency = isExplicitReferencedDependency, | |
| IsDevelopmentDependency = isDevelopmentDependency, | |
| DependencyScope = dependencyScope, | |
| }; | |
| this.DependencyGraph.AddComponent(componentNode, parentComponentId); | |
| } |
So, the dependency graph has the proper value, but the component recorder's DetectedComponent, which is used for experiments, does not have DevelopmentDependency set.
I'm not entirely sure this applies to just NPM, I think all DetectedComponents don't properly have the development dependency flag set. Perhaps the ComponentRecorder should handle this automatically.