Skip to content

Commit 3b56bac

Browse files
author
Robert Holt
committed
Fix asm duplicate name crash
1 parent 1ff4d9f commit 3b56bac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

PSCompatibilityAnalyzer/Microsoft.PowerShell.CrossCompatibility/Utility/TypeDataConversion.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ public static AvailableTypeData AssembleAvailableTypes(
6161

6262
try
6363
{
64+
// First check whether an assembly with this name already exists
65+
// Only replace it if the current one is newer
66+
AssemblyName asmName = asm.GetName();
67+
if (asms.TryGetValue(asmName.Name, out AssemblyData currentAssemblyData)
68+
&& asmName.Version < currentAssemblyData.AssemblyName.Version)
69+
{
70+
continue;
71+
}
72+
6473
KeyValuePair<string, AssemblyData> asmData = AssembleAssembly(asm);
6574
asms[asmData.Key] = asmData.Value;
6675
}

0 commit comments

Comments
 (0)