@@ -84,6 +84,13 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
84
84
85
85
var metadata = CargoMetadata . FromJson ( cliResult . StdOut ) ;
86
86
var graph = BuildGraph ( metadata ) ;
87
+
88
+ var packages = metadata . Packages . ToDictionary (
89
+ x => $ "{ x . Name } { x . Version } ",
90
+ x => (
91
+ ( x . Authors == null || x . Authors . Any ( a => string . IsNullOrWhiteSpace ( a ) ) || ! x . Authors . Any ( ) ) ? null : string . Join ( ", " , x . Authors ) ,
92
+ string . IsNullOrWhiteSpace ( x . License ) ? null : x . License ) ) ;
93
+
87
94
var root = metadata . Resolve . Root ;
88
95
89
96
// A cargo.toml can be used to declare a workspace and not a package (A Virtual Manifest).
@@ -95,7 +102,7 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
95
102
return ;
96
103
}
97
104
98
- this . TraverseAndRecordComponents ( processRequest . SingleFileComponentRecorder , componentStream . Location , graph , root , null , null ) ;
105
+ this . TraverseAndRecordComponents ( processRequest . SingleFileComponentRecorder , componentStream . Location , graph , root , null , null , packages ) ;
99
106
}
100
107
catch ( InvalidOperationException e )
101
108
{
@@ -118,13 +125,19 @@ private void TraverseAndRecordComponents(
118
125
string id ,
119
126
DetectedComponent parent ,
120
127
Dep depInfo ,
128
+ IReadOnlyDictionary < string , ( string Authors , string License ) > packagesMetadata ,
121
129
bool explicitlyReferencedDependency = false )
122
130
{
123
131
try
124
132
{
125
133
var isDevelopmentDependency = depInfo ? . DepKinds . Any ( x => x . Kind is Kind . Dev ) ?? false ;
126
134
var ( name , version ) = ParseNameAndVersion ( id ) ;
127
- var detectedComponent = new DetectedComponent ( new CargoComponent ( name , version ) ) ;
135
+
136
+ var ( authors , license ) = packagesMetadata . TryGetValue ( $ "{ name } { version } ", out var package )
137
+ ? package
138
+ : ( null , null ) ;
139
+
140
+ var detectedComponent = new DetectedComponent ( new CargoComponent ( name , version , authors , license ) ) ;
128
141
129
142
recorder . RegisterUsage (
130
143
detectedComponent ,
@@ -140,7 +153,7 @@ private void TraverseAndRecordComponents(
140
153
141
154
foreach ( var dep in node . Deps )
142
155
{
143
- this . TraverseAndRecordComponents ( recorder , location , graph , dep . Pkg , detectedComponent , dep , parent == null ) ;
156
+ this . TraverseAndRecordComponents ( recorder , location , graph , dep . Pkg , detectedComponent , dep , packagesMetadata , parent == null ) ;
144
157
}
145
158
}
146
159
catch ( IndexOutOfRangeException e )
0 commit comments