Fix for issue object.GetHashCode not working
I've improved the GetHashCode method and return the CRC32 of the heap block address if the instance has no fields.
@@ -967,11 +967,18 @@ CLR_UINT32 CLR_RT_HeapBlock::GetHashCode( CLR_RT_HeapBlock* ptr, bool fRecurse,
CLR_RT_TypeDef_Instance cls; cls.InitializeFromIndex( ptr->ObjectCls() );
int totFields = cls.CrossReference().m_totalFields;
+ if (totFields > 0)
+ {
while(totFields-- > 0)
{
crc = GetHashCode( ++ptr, false, crc );
}
}
+ else
+ {
+ crc = SUPPORT_ComputeCRC( &ptr, sizeof(ptr), crc );
+ }
+ }
break;
case DATATYPE_DELEGATE_HEAD:
