|
|
@ -17,10 +17,54 @@ |
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
|
|
|
|
#if !NET40 && ROSLYN
|
|
|
|
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
|
|
|
|
#endif
|
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
|
|
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
internal class SizeofTest |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
private struct StructWithStaticField |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public static object StaticObj; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IntPtr A; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private struct UnmanagedStruct |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public StructWithStaticField Value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private struct ManagedStruct |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public object Obj; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#if CS73
|
|
|
|
|
|
|
|
private unsafe int GenericMethod<T>() where T : unmanaged |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return sizeof(T); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private unsafe void Test(out int s1, out int s2, out int s3) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
s1 = 0; |
|
|
|
|
|
|
|
s2 = 0; |
|
|
|
|
|
|
|
s3 = 0; |
|
|
|
|
|
|
|
#if CS73
|
|
|
|
|
|
|
|
GenericMethod<UnmanagedStruct>(); |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
s1 = sizeof(UnmanagedStruct); |
|
|
|
|
|
|
|
#if !NET40 && ROSLYN
|
|
|
|
|
|
|
|
s2 = Unsafe.SizeOf<UnmanagedStruct>(); |
|
|
|
|
|
|
|
s3 = Unsafe.SizeOf<ManagedStruct>(); |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class UnsafeCode |
|
|
|
public class UnsafeCode |
|
|
|
{ |
|
|
|
{ |
|
|
|
public struct SimpleStruct |
|
|
|
public struct SimpleStruct |
|
|
|