Skip to content

Commit 5b78994

Browse files
authored
Fix FieldRef and FieldDef (#208)
1 parent 664eb25 commit 5b78994

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

MetadataProcessor.Shared/Tables/nanoFieldDefinitionTable.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class nanoFieldDefinitionTable :
2222
//////////////////////////////////////////////////////////////////////////////////////////////
2323
// <SYNC-WITH-NATIVE> //
2424
// when updating this size here need to update matching define in nanoCLR_Types.h in native //
25-
private const int sizeOf_CLR_RECORD_FIELDDEF = 8;
25+
private const int sizeOf_CLR_RECORD_FIELDDEF = 10;
2626
//////////////////////////////////////////////////////////////////////////////////////////////
2727
//////////////////////////////////////////////////////////////////////////////////////////////
2828

@@ -35,13 +35,13 @@ private sealed class FieldDefinitionComparer : IEqualityComparer<FieldDefinition
3535
/// <inheritdoc/>
3636
public bool Equals(FieldDefinition lhs, FieldDefinition rhs)
3737
{
38-
return string.Equals(lhs.FullName, rhs.FullName, StringComparison.Ordinal);
38+
return lhs.MetadataToken.Equals(rhs.MetadataToken);
3939
}
4040

4141
/// <inheritdoc/>
4242
public int GetHashCode(FieldDefinition that)
4343
{
44-
return that.FullName.GetHashCode();
44+
return that.MetadataToken.GetHashCode();
4545
}
4646
}
4747

@@ -81,6 +81,7 @@ protected override void WriteSingleItem(
8181

8282
var writerStartPosition = writer.BaseStream.Position;
8383

84+
WriteStringReference(writer, item.DeclaringType.Name);
8485
WriteStringReference(writer, item.Name);
8586
writer.WriteUInt16(_context.SignaturesTable.GetOrCreateSignatureId(item));
8687

MetadataProcessor.Shared/Tables/nanoFieldReferenceTable.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class nanoFieldReferenceTable :
2222
//////////////////////////////////////////////////////////////////////////////////////////////
2323
// <SYNC-WITH-NATIVE> //
2424
// when updating this size here need to update matching define in nanoCLR_Types.h in native //
25-
private const int sizeOf_CLR_RECORD_FIELDREF = 6;
25+
private const int sizeOf_CLR_RECORD_FIELDREF = 8;
2626
//////////////////////////////////////////////////////////////////////////////////////////////
2727
//////////////////////////////////////////////////////////////////////////////////////////////
2828

@@ -35,13 +35,13 @@ private sealed class MemberReferenceComparer : IEqualityComparer<FieldReference>
3535
/// <inheritdoc/>
3636
public bool Equals(FieldReference lhs, FieldReference rhs)
3737
{
38-
return string.Equals(lhs.FullName, rhs.FullName, StringComparison.Ordinal);
38+
return lhs.MetadataToken.Equals(rhs.MetadataToken);
3939
}
4040

4141
/// <inheritdoc/>
4242
public int GetHashCode(FieldReference that)
4343
{
44-
return that.FullName.GetHashCode();
44+
return that.MetadataToken.GetHashCode();
4545
}
4646
}
4747

@@ -99,6 +99,9 @@ protected override void WriteSingleItem(
9999
throw new ArgumentException($"Can't find a type reference for {item.DeclaringType}.");
100100
}
101101

102+
// Type
103+
WriteStringReference(writer, item.DeclaringType.Name);
104+
102105
// Name
103106
WriteStringReference(writer, item.Name);
104107

0 commit comments

Comments
 (0)