What do angled brackets mean when used in member name in C#?
Asked Answered
G

1

1

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?

Gorrono answered 8/9, 2012 at 10:25 Comment(2)
I can only think it's something added by DotPeek.Unthoughtof
Yes, it's not valid as C# source code.Enidenigma
G
2

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.

Gaillard answered 8/9, 2012 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.