diff --git a/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs b/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs index 0c91acb42c7d5f..1e0b8a9311dfb0 100644 --- a/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs +++ b/src/coreclr/tools/Common/TypeSystem/Sorting/TypeSystemComparer.cs @@ -25,7 +25,7 @@ namespace Internal.TypeSystem // to sort itself with respect to other instances of the same type. // Comparisons between different categories of types are centralized to a single location that // can provide rules to sort them. - public class TypeSystemComparer : IComparer, IComparer, IComparer, IComparer + public class TypeSystemComparer : IComparer, IComparer, IComparer, IComparer, IComparer { public static TypeSystemComparer Instance { get; } = new TypeSystemComparer(); @@ -128,5 +128,10 @@ public int Compare(MethodSignature x, MethodSignature y) { return x.CompareTo(y, this); } + + public int Compare(ModuleDesc x, ModuleDesc y) + { + return Compare(x.GetGlobalModuleType(), y.GetGlobalModuleType()); + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs index bd3e1069881361..60a4c0b14f1b74 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs @@ -50,7 +50,7 @@ private static (string AttributeName, DiagnosticId Id)[] _requiresAttributeMisma }; private readonly List _typesWithForcedEEType = new List(); - private readonly List _modulesWithMetadata = new List(); + private readonly SortedSet _modulesWithMetadata = new SortedSet(CompilerComparer.Instance); private readonly List _fieldsWithMetadata = new List(); private readonly List _methodsWithMetadata = new List(); private readonly List _typesWithMetadata = new List();