diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs index ea73a31460503..b88f8a42fc3e8 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs @@ -192,9 +192,14 @@ private RoType[] ComputeInterfaceClosure() } } - // todo: use IEnumerable extension: return ifcs.ToArray() - List list = new List(ifcs); - return list.ToArray(); + if (ifcs.Count == 0) + { + return Array.Empty(); + } + + var arr = new RoType[ifcs.Count]; + ifcs.CopyTo(arr); + return arr; } private volatile RoType[]? _lazyInterfaces;