Skip to content

Commit eeb86e9

Browse files
ViktorHoferericstj
andauthored
Ignore internal .NET Framework assemblies in AssemblySymbolLoader (#46059)
Co-authored-by: Eric StJohn <[email protected]>
1 parent c3bc2e9 commit eeb86e9

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ namespace Microsoft.DotNet.ApiSymbolExtensions
1616
/// </summary>
1717
public class AssemblySymbolLoader : IAssemblySymbolLoader
1818
{
19+
// This is a list of dangling .NET Framework internal assemblies that should never get loaded.
20+
private static readonly HashSet<string> s_assembliesToIgnore = [
21+
"System.ServiceModel.Internals",
22+
"Microsoft.Internal.Tasks.Dataflow",
23+
"MSDATASRC",
24+
"ADODB",
25+
"Microsoft.StdFormat",
26+
"stdole",
27+
"PresentationUI",
28+
"Microsoft.VisualBasic.Activities.Compiler",
29+
"SMDiagnostics",
30+
"System.Xaml.Hosting",
31+
"Microsoft.Transactions.Bridge",
32+
"Microsoft.Workflow.Compiler"
33+
];
34+
1935
private readonly ILog _log;
2036
// Dictionary that holds the paths to help loading dependencies. Keys will be assembly name and
2137
// value are the containing folder.
@@ -339,13 +355,18 @@ private void ResolveReferences(PEReader peReader, ImmutableHashSet<string>? refe
339355
foreach (AssemblyReferenceHandle handle in reader.AssemblyReferences)
340356
{
341357
AssemblyReference reference = reader.GetAssemblyReference(handle);
342-
string name = $"{reader.GetString(reference.Name)}.dll";
358+
string nameWithoutExtension = reader.GetString(reference.Name);
359+
360+
// Skip assemblies that should never get loaded because they are purely internal
361+
if (s_assembliesToIgnore.Contains(nameWithoutExtension))
362+
continue;
363+
364+
string name = nameWithoutExtension + ".dll";
343365

344366
// Skip reference assemblies that are loaded later.
345367
if (referenceAssemblyNamesToIgnore != null && referenceAssemblyNamesToIgnore.Contains(name))
346368
continue;
347369

348-
349370
// If the assembly reference is already loaded, don't do anything.
350371
if (_loadedAssemblies.ContainsKey(name))
351372
continue;

0 commit comments

Comments
 (0)