What do angled brackets mean when used in member n

2019-07-30 09:59发布

问题:

I was browsing through sources of PresentationCore.dll using DotPeek when I found this:

// Type: MS.Internal.TtfDelta.CMAP_HEADER
// Assembly: PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// Assembly location: D:\Windows\Microsoft.NET\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace MS.Internal.TtfDelta
{
  [NativeCppClass]
  [StructLayout(LayoutKind.Sequential, Size = 4)]
  internal struct CMAP_HEADER
  {
    private short <alignment member>;
  }
}

What does "private short <alignment member>" mean?

回答1:

Sometimes the disassembler doesn't know what a member of the code actually is, and it'll use a "guessed" type.

Disassemblers provide us with pseudo-code, even though it's very accurate in the case of dotPeek being used on the .NET Framework, it still isn't "real" code, like the base.ctor call in the following HashEntry class:

private class HashEntry
{
  public string[] names;
  public ulong[] values;

  public HashEntry(string[] names, ulong[] values)
  {
    base.\u002Ector();
    this.names = names;
    this.values = values;
  }
}

Which I took from mscorlib demonstrates this perfectly.