Created
April 23, 2015 12:19
-
-
Save Scooletz/9b78bd52451f76ba0eea to your computer and use it in GitHub Desktop.
nullable alignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestX | |
{ | |
[Test] | |
public void T() | |
{ | |
Inspect(typeof(int)); | |
Inspect(typeof(long)); | |
Inspect(typeof(bool)); | |
Inspect(typeof(Guid)); | |
} | |
private static void Inspect(Type t) | |
{ | |
var type = typeof (Nullable<>).MakeGenericType(t); | |
Console.WriteLine(type.FullName.Replace(", mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "") + ":"); | |
Console.WriteLine(Marshal.OffsetOf(type, "hasValue")); | |
Console.WriteLine(Marshal.OffsetOf(type, "value")); | |
Console.WriteLine(typeof (Marshal).InvokeMember("SizeOfHelper", | |
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Static, null, null, | |
new object[] {type, true})); | |
Console.WriteLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment