Is the order of fields in the ILDASM tree view correct or is the order in the MetaInfo correct?

StackOverflow https://stackoverflow.com/questions/10925406

  •  13-06-2021
  •  | 
  •  

Вопрос

In trying to determine the precise order of fields in a .NET value type, I looked both at the ILDASM tree view and at the ILDASM "MetaInfo" (i.e., the actual IL). The order of fields in the two views of the data is inverse.

For example, the tree view of System.Runtime.InteropServices.FILETIME lists dwHighDateTime before dwLowDateTime. (I would post an image, but lack enough reputation points here to do so).

On the other hand, here is the corresponding IL, using View>>MetaInfo>>Show! in ILDASM:

TypeDef #1655 (02000678)

TypDefName: System.Runtime.InteropServices.FILETIME  (02000678)
Flags     : [Public] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100109)
Extends   : 02000009 [TypeDef] System.ValueType
Field #1 (04001e2e)
-------------------------------------------------------
    Field Name: dwLowDateTime (04001E2E)
    Flags     : [Public]  (00000006)
    CallCnvntn: [FIELD]
    Field type:  I4

Field #2 (04001e2f)
-------------------------------------------------------
    Field Name: dwHighDateTime (04001E2F)
    Flags     : [Public]  (00000006)
    CallCnvntn: [FIELD]
    Field type:  I4

...

Which is the correct order? I assume the IL is correct, but would like confirmation. Does anyone know the reason for this disparity?

Это было полезно?

Решение

Looks like the Win32 FILETIME struct is little-endian (low part first). The .net version being an interop struct, and thus made for interacting with native code, it would pretty much have to be compatible with the native one.

As for the reason behind the "disparity", note that "dwHighDateTime" comes before "dwLowDateTime" in alphabetical order.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top