Skip to content

Commit 9c8a9c1

Browse files
committed
feat: fixing logic that missed certain cases of bad prefix
1 parent 7fa37d4 commit 9c8a9c1

File tree

9 files changed

+19
-1067
lines changed

9 files changed

+19
-1067
lines changed

lib/nuget-parser/parsers/dotnet-core-v2-parser.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ interface DotnetPackage {
1717
}
1818

1919
// Dependencies that starts with these are discarded
20-
export const FILTERED_DEPENDENCY_PREFIX = ['runtime'];
20+
export const FILTERED_DEPENDENCY_PREFIX = [
21+
// `runtime` and `runtime.native` are a bit of a hot topic, see more https://github.com/dotnet/core/issues/7568.
22+
// For our case, we are already creating the correct dependencies and their respective runtime version numbers based
23+
// of our runtime resolution logic. So a dependency will already be `[email protected]` if running on .NET 8, thus
24+
// removing the need for a `[email protected]` as well. From our investigation these runtime native
25+
// dependencies are causing noise for the customers and are not of interested.
26+
'runtime',
27+
];
2128

2229
// The list of top level dependencies and transitive dependencies differ based on the target runtime we've defined.
2330
// In the generated dependency file created by the `dotnet` CLI, this is organized by the target framework moniker (TFM).
@@ -72,6 +79,13 @@ function recursivelyPopulateNodes(
7279
const name = depNode[0];
7380
const version = depNode[1];
7481

82+
// Ignore packages with specific prefixes, which for one reason or the other are no interesting and pollutes the
83+
// graph. Refer to comments on the individual elements in the ignore list for more information.
84+
if (FILTERED_DEPENDENCY_PREFIX.some((prefix) => name.startsWith(prefix))) {
85+
debug(`${name} matched a prefix we ignore, not adding to graph`);
86+
continue;
87+
}
88+
7589
const childNode = {
7690
...targetDeps[`${name}/${version}`],
7791
name,
@@ -179,16 +193,6 @@ function buildGraph(
179193
targetFrameworkDependencies,
180194
).reduce((acc, entry) => {
181195
const [nameWithVersion, pkg] = entry;
182-
183-
// Ignore packages with specific prefixes, which for one reason or the other are no interesting and pollutes the graph.
184-
if (
185-
FILTERED_DEPENDENCY_PREFIX.some((prefix) =>
186-
nameWithVersion.startsWith(prefix),
187-
)
188-
) {
189-
return acc;
190-
}
191-
192196
return { ...acc, [nameWithVersion]: pkg };
193197
}, {});
194198

test/fixtures/dotnetcore/dotnet_6/expected_depgraph.json

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,6 @@
208208
"version": "6.0.0"
209209
}
210210
},
211-
{
212-
213-
"info": {
214-
"name": "runtime.native.System",
215-
"version": "4.3.0"
216-
}
217-
},
218-
{
219-
220-
"info": {
221-
"name": "runtime.native.System.IO.Compression",
222-
"version": "4.3.0"
223-
}
224-
},
225211
{
226212
227213
"info": {
@@ -355,20 +341,6 @@
355341
"version": "6.0.0"
356342
}
357343
},
358-
{
359-
360-
"info": {
361-
"name": "runtime.native.System.Security.Cryptography.OpenSsl",
362-
"version": "4.3.0"
363-
}
364-
},
365-
{
366-
367-
"info": {
368-
"name": "runtime.native.System.Security.Cryptography.Apple",
369-
"version": "4.3.0"
370-
}
371-
},
372344
{
373345
374346
"info": {
@@ -397,13 +369,6 @@
397369
"version": "6.0.0"
398370
}
399371
},
400-
{
401-
402-
"info": {
403-
"name": "runtime.native.System.Net.Http",
404-
"version": "4.3.0"
405-
}
406-
},
407372
{
408373
409374
"info": {
@@ -1195,12 +1160,6 @@
11951160
},
11961161
{
11971162
"nodeId": "[email protected]:pruned"
1198-
},
1199-
{
1200-
"nodeId": "[email protected]"
1201-
},
1202-
{
1203-
"nodeId": "[email protected]"
12041163
}
12051164
]
12061165
},
@@ -1314,16 +1273,6 @@
13141273
}
13151274
}
13161275
},
1317-
{
1318-
"nodeId": "[email protected]",
1319-
"pkgId": "[email protected]",
1320-
"deps": []
1321-
},
1322-
{
1323-
"nodeId": "[email protected]",
1324-
"pkgId": "[email protected]",
1325-
"deps": []
1326-
},
13271276
{
13281277
"nodeId": "[email protected]",
13291278
"pkgId": "[email protected]",
@@ -1711,15 +1660,6 @@
17111660
},
17121661
{
17131662
"nodeId": "[email protected]:pruned"
1714-
},
1715-
{
1716-
"nodeId": "[email protected]:pruned"
1717-
},
1718-
{
1719-
"nodeId": "[email protected]:pruned"
1720-
},
1721-
{
1722-
"nodeId": "[email protected]:pruned"
17231663
}
17241664
]
17251665
},
@@ -1835,12 +1775,6 @@
18351775
},
18361776
{
18371777
"nodeId": "[email protected]:pruned"
1838-
},
1839-
{
1840-
"nodeId": "[email protected]"
1841-
},
1842-
{
1843-
"nodeId": "[email protected]:pruned"
18441778
}
18451779
]
18461780
},
@@ -1898,9 +1832,6 @@
18981832
},
18991833
{
19001834
"nodeId": "[email protected]:pruned"
1901-
},
1902-
{
1903-
"nodeId": "[email protected]"
19041835
}
19051836
]
19061837
},
@@ -1941,11 +1872,6 @@
19411872
}
19421873
]
19431874
},
1944-
{
1945-
"nodeId": "[email protected]",
1946-
"pkgId": "[email protected]",
1947-
"deps": []
1948-
},
19491875
{
19501876
"nodeId": "[email protected]:pruned",
19511877
"pkgId": "[email protected]",
@@ -1956,21 +1882,6 @@
19561882
}
19571883
}
19581884
},
1959-
{
1960-
"nodeId": "[email protected]",
1961-
"pkgId": "[email protected]",
1962-
"deps": []
1963-
},
1964-
{
1965-
"nodeId": "[email protected]:pruned",
1966-
"pkgId": "[email protected]",
1967-
"deps": [],
1968-
"info": {
1969-
"labels": {
1970-
"pruned": "true"
1971-
}
1972-
}
1973-
},
19741885
{
19751886
"nodeId": "[email protected]:pruned",
19761887
"pkgId": "[email protected]",
@@ -2020,9 +1931,6 @@
20201931
},
20211932
{
20221933
"nodeId": "[email protected]:pruned"
2023-
},
2024-
{
2025-
"nodeId": "[email protected]:pruned"
20261934
}
20271935
]
20281936
},
@@ -2115,15 +2023,6 @@
21152023
},
21162024
{
21172025
"nodeId": "[email protected]:pruned"
2118-
},
2119-
{
2120-
"nodeId": "[email protected]:pruned"
2121-
},
2122-
{
2123-
"nodeId": "[email protected]"
2124-
},
2125-
{
2126-
"nodeId": "[email protected]:pruned"
21272026
}
21282027
]
21292028
},
@@ -2231,31 +2130,6 @@
22312130
}
22322131
}
22332132
},
2234-
{
2235-
"nodeId": "[email protected]:pruned",
2236-
"pkgId": "[email protected]",
2237-
"deps": [],
2238-
"info": {
2239-
"labels": {
2240-
"pruned": "true"
2241-
}
2242-
}
2243-
},
2244-
{
2245-
"nodeId": "[email protected]",
2246-
"pkgId": "[email protected]",
2247-
"deps": []
2248-
},
2249-
{
2250-
"nodeId": "[email protected]:pruned",
2251-
"pkgId": "[email protected]",
2252-
"deps": [],
2253-
"info": {
2254-
"labels": {
2255-
"pruned": "true"
2256-
}
2257-
}
2258-
},
22592133
{
22602134
"nodeId": "[email protected]:pruned",
22612135
"pkgId": "[email protected]",
@@ -2331,9 +2205,6 @@
23312205
},
23322206
{
23332207
"nodeId": "[email protected]:pruned"
2334-
},
2335-
{
2336-
"nodeId": "[email protected]:pruned"
23372208
}
23382209
]
23392210
},
@@ -2740,9 +2611,6 @@
27402611
},
27412612
{
27422613
"nodeId": "[email protected]:pruned"
2743-
},
2744-
{
2745-
"nodeId": "[email protected]:pruned"
27462614
}
27472615
]
27482616
},

0 commit comments

Comments
 (0)