Skip to content

Commit

Permalink
[mono] Fix sorting custom attributes in ILStrip (#88435)
Browse files Browse the repository at this point in the history
The change in #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.
  • Loading branch information
akoeplinger committed Jul 5, 2023
1 parent 3be1483 commit 47f47b8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public int Compare(object left, object right)
{
CustomAttributeRow row_left = (CustomAttributeRow)left;
CustomAttributeRow row_right = (CustomAttributeRow)right;
return row_left.Parent.RID.CompareTo(row_right.Parent.RID);
var leftParentCodedIdx = Utilities.CompressMetadataToken(CodedIndex.HasCustomAttribute, row_left.Parent);
var rightParentCodedIdx = Utilities.CompressMetadataToken(CodedIndex.HasCustomAttribute, row_right.Parent);
return leftParentCodedIdx.CompareTo(rightParentCodedIdx);
}
}

Expand Down

0 comments on commit 47f47b8

Please sign in to comment.