Skip to content

Commit

Permalink
Update InterfaceImpl sorting, closes #426
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Dec 6, 2021
1 parent 2d1a918 commit b656bf9
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/DotNet/Writer/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using dnlib.IO;
using dnlib.PE;
using dnlib.DotNet.MD;
using dnlib.DotNet.Emit;
using System.Diagnostics;
using dnlib.DotNet.MD;
using dnlib.DotNet.Pdb;
using dnlib.DotNet.Pdb.Portable;
using System.Linq;
using dnlib.IO;
using dnlib.PE;

namespace dnlib.DotNet.Writer {
/// <summary>
Expand Down Expand Up @@ -158,6 +158,7 @@ public enum MetadataFlags : uint {
AlwaysCreateBlobHeap = 0x80000,

/// <summary>
/// DEPRECATED:
/// Sort the InterfaceImpl table the same way Roslyn sorts it. Roslyn doesn't sort it
/// according to the ECMA spec, see https://github.com/dotnet/roslyn/issues/3905
/// </summary>
Expand Down Expand Up @@ -1822,15 +1823,7 @@ void SortTables() {
return a.row.Owner.CompareTo(b.row.Owner);
return a.row.Number.CompareTo(b.row.Number);
});
if (RoslynSortInterfaceImpl)
interfaceImplInfos.Sort((a, b) => a.row.Class.CompareTo(b.row.Class));
else {
interfaceImplInfos.Sort((a, b) => {
if (a.row.Class != b.row.Class)
return a.row.Class.CompareTo(b.row.Class);
return a.row.Interface.CompareTo(b.row.Interface);
});
}
interfaceImplInfos.Sort((a, b) => a.row.Class.CompareTo(b.row.Class));

tablesHeap.ClassLayoutTable.IsSorted = true;
tablesHeap.ConstantTable.IsSorted = true;
Expand Down

0 comments on commit b656bf9

Please # to comment.