Skip to content

Commit aae04d0

Browse files
committed
[mono] Fix sorting custom attributes in ILStrip
The change in dotnet#87923 was subtly wrong, the problem is that RID on a Cecil metadata token masks out the token type. We actually have to reconstruct the custom attribute coded-index.
1 parent 76a8f4f commit aae04d0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tasks/MonoTargetsTasks/ILStrip/AssemblyStripper/AssemblyStripper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public int Compare(object left, object right)
1818
{
1919
CustomAttributeRow row_left = (CustomAttributeRow)left;
2020
CustomAttributeRow row_right = (CustomAttributeRow)right;
21-
return row_left.Parent.RID.CompareTo(row_right.Parent.RID);
21+
var leftParentCodedIdx = Utilities.CompressMetadataToken(CodedIndex.HasCustomAttribute, row_left.Parent);
22+
var rightParentCodedIdx = Utilities.CompressMetadataToken(CodedIndex.HasCustomAttribute, row_right.Parent);
23+
return leftParentCodedIdx.CompareTo(rightParentCodedIdx);
2224
}
2325
}
2426

0 commit comments

Comments
 (0)