forked from microsoft/component-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIComponentRecorder.cs
108 lines (88 loc) · 4.92 KB
/
IComponentRecorder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System.Collections.Generic;
using Microsoft.ComponentDetection.Contracts.BcdeModels;
namespace Microsoft.ComponentDetection.Contracts
{
public interface IComponentRecorder
{
TypedComponent.TypedComponent GetComponent(string componentId);
IEnumerable<DetectedComponent> GetDetectedComponents();
ISingleFileComponentRecorder CreateSingleFileComponentRecorder(string location);
IReadOnlyDictionary<string, IDependencyGraph> GetDependencyGraphsByLocation();
}
public interface ISingleFileComponentRecorder
{
string ManifestFileLocation { get; }
/// <summary>
/// Add or Update a component. In case that a parent componentId is specified
/// an edge is created between those components in the dependency graph.
/// </summary>
/// <param name="detectedComponent">Component to add.</param>
/// <param name="isExplicitReferencedDependency">The value define if the component was referenced manually by the user in the location where the scanning is taking place.</param>
/// <param name="parentComponentId">Id of the parent component.</param>
/// <param name="isDevelopmentDependency">Boolean value indicating whether or not a component is a development-time dependency. Null implies that the value is unknown.</param>
/// <param name="dependencyScope">Enum value indicating scope of the component. </param>
/// <returns>DetectedComponent added or updated.</returns>
void RegisterUsage(
DetectedComponent detectedComponent,
bool isExplicitReferencedDependency = false,
string parentComponentId = null,
bool? isDevelopmentDependency = null,
DependencyScope? dependencyScope = null);
DetectedComponent GetComponent(string componentId);
void AddAdditionalRelatedFile(string relatedFilePath);
IReadOnlyDictionary<string, DetectedComponent> GetDetectedComponents();
IComponentRecorder GetParentComponentRecorder();
IDependencyGraph DependencyGraph { get; }
}
public interface IDependencyGraph
{
/// <summary>
/// Gets the componentIds that are dependencies for a given componentId.
/// </summary>
/// <param name="componentId">The component id to look up dependencies for.</param>
/// <returns>The componentIds that are dependencies for a given componentId.</returns>
IEnumerable<string> GetDependenciesForComponent(string componentId);
/// <summary>
/// Gets all componentIds that are in the dependency graph.
/// </summary>
/// <returns>The componentIds that are part of the dependency graph.</returns>
IEnumerable<string> GetComponents();
/// <summary>
/// Returns true if a componentId is an explicitly referenced dependency.
/// </summary>
/// <param name="componentId">The componentId to check.</param>
/// <returns>True if explicitly referenced, false otherwise.</returns>
bool IsComponentExplicitlyReferenced(string componentId);
HashSet<string> GetAdditionalRelatedFiles();
/// <summary>
/// Returns true if a componentId is registered in the graph.
/// </summary>
/// <param name="componentId">The componentId to check.</param>
/// <returns>True if registered in the graph, false otherwise.</returns>
bool Contains(string componentId);
/// <summary>
/// Returns true if a componentId is a development dependency, and false if it is not.
/// Null can be returned if a detector doesn't have confidence one way or the other.
/// </summary>
/// <param name="componentId">The componentId to check.</param>
/// <returns>True if a development dependency, false if not. Null when unknown.</returns>
bool? IsDevelopmentDependency(string componentId);
/// <summary>
/// Returns DepedencyScope for the given componentId.
/// Null can be returned if a detector doesn't have the scope infromation.
/// </summary>
/// <param name="componentId">The componentId to check.</param>
DependencyScope? GetDependencyScope(string componentId);
/// <summary>
/// Gets the component IDs of all explicitly referenced components.
/// </summary>
/// <returns>An enumerable of the component IDs of all explicilty referenced components.</returns>
IEnumerable<string> GetAllExplicitlyReferencedComponents();
/// <summary>
/// Returns the set of component ids that are explicit references to the given component id.
/// </summary>
/// <param name="componentId">The leaf level component to find explicit references for.</param>
/// <returns>A collection fo all explicit references to the given component.</returns>
ICollection<string> GetExplicitReferencedDependencyIds(string componentId);
}
}