Don't set sequential type attribute for async containers
authorMarek Safar <marek.safar@gmail.com>
Tue, 30 Oct 2012 14:57:22 +0000 (15:57 +0100)
committerMarek Safar <marek.safar@gmail.com>
Tue, 30 Oct 2012 14:57:22 +0000 (15:57 +0100)
mcs/mcs/async.cs
mcs/mcs/class.cs

index 47ae75708707c7a4c2382dd7a420ad715df79453..6de09f01b1a9d83ff4a899f8cff922549a19e19d 100644 (file)
@@ -7,7 +7,7 @@
 // Dual licensed under the terms of the MIT X11 or GNU GPL
 //
 // Copyright 2011 Novell, Inc.
-// Copyright 2011 Xamarin Inc.
+// Copyright 2011-2012 Xamarin Inc.
 //
 
 using System;
@@ -16,8 +16,10 @@ using System.Linq;
 using System.Collections;
 
 #if STATIC
+using IKVM.Reflection;
 using IKVM.Reflection.Emit;
 #else
+using System.Reflection;
 using System.Reflection.Emit;
 #endif
 
@@ -486,6 +488,12 @@ namespace Mono.CSharp
                        }
                }
 
+               protected override TypeAttributes TypeAttr {
+                       get {
+                               return base.TypeAttr & ~TypeAttributes.SequentialLayout;
+                       }
+               }
+
                #endregion
 
                public Field AddAwaiter (TypeSpec type, Location loc)
index bd2c129d9e3abdc2828d60f52f8e175e4370cd4c..567b2fadf300ef7e81b7c0345856ef98c8b310b9 100644 (file)
@@ -1218,7 +1218,7 @@ namespace Mono.CSharp
                        //
                        // Sets .size to 1 for structs with no instance fields
                        //
-                       int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null ? 1 : 0;
+                       int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null && !(this is StateMachine) ? 1 : 0;
 
                        var parent_def = Parent as TypeDefinition;
                        if (parent_def == null) {