2005-12-23 Miguel de Icaza <miguel@novell.com>
[mono.git] / mcs / mcs / class.cs
index c7670a1cefce374ed95aace4763d3ff73357c9d1..4a723460b316d334c973294378151ef994f5aaa1 100644 (file)
@@ -64,15 +64,6 @@ namespace Mono.CSharp {
        /// </summary>
        public abstract class TypeContainer : DeclSpace, IMemberContainer {
 
-               protected class CircularDepException: Exception
-               {
-                       public TypeContainer Container;
-                       public CircularDepException (TypeContainer tc)
-                       {
-                               Container = tc;
-                       }
-               }
-
                public class MemberCoreArrayList: ArrayList
                {
                        /// <summary>
@@ -92,7 +83,7 @@ namespace Mono.CSharp {
                        }
                }
 
-               public class MethodArrayList: MemberCoreArrayList
+               public class MethodArrayList : MemberCoreArrayList
                {
                        [Flags]
                        enum CachedMethods {
@@ -138,14 +129,14 @@ namespace Mono.CSharp {
                        {
                                base.DefineContainerMembers ();
  
-                               if ((RootContext.WarningLevel >= 3) && HasEquals && !HasGetHashCode) {
-                                       Report.Warning (659, container.Location, "'{0}' overrides Object.Equals(object) but does not override Object.GetHashCode()", container.GetSignatureForError ());
+                               if (HasEquals && !HasGetHashCode) {
+                                       Report.Warning (659, 3, container.Location, "`{0}' overrides Object.Equals(object) but does not override Object.GetHashCode()", container.GetSignatureForError ());
                                }
                        }
  
                }
 
-               public sealed class IndexerArrayList: MemberCoreArrayList
+               public sealed class IndexerArrayList : MemberCoreArrayList
                {
                        /// <summary>
                        /// The indexer name for this container
@@ -279,7 +270,7 @@ namespace Mono.CSharp {
                        //
                        void CheckPairedOperators ()
                        {
-                               Hashtable pairs = new Hashtable (null, null);
+                               IDictionary pairs = new HybridDictionary ();
                                Operator true_op = null;
                                Operator false_op = null;
                                bool has_equality_or_inequality = false;
@@ -335,9 +326,11 @@ namespace Mono.CSharp {
 
                                if (true_op != null){
                                        if (false_op == null)
-                                               Report.Error (216, true_op.Location, "operator true requires a matching operator false");
+                                               Report.Error (216, true_op.Location, "The operator `{0}' requires a matching operator `false' to also be defined",
+                                                       true_op.GetSignatureForError ());
                                } else if (false_op != null)
-                                       Report.Error (216, false_op.Location, "operator false requires a matching operator true");
+                                       Report.Error (216, false_op.Location, "The operator `{0}' requires a matching operator `true' to also be defined",
+                                               false_op.GetSignatureForError ());
                                
                                //
                                // Look for the mistakes.
@@ -370,15 +363,16 @@ namespace Mono.CSharp {
                                                break;
                                        }
                                        Report.Error (216, oe.op.Location,
-                                                       "The operator `" + oe.op + "' requires a matching operator `" + s + "' to also be defined");
+                                               "The operator `{0}' requires a matching operator `{1}' to also be defined",
+                                               oe.op.GetSignatureForError (), s);
                                }
 
                                if (has_equality_or_inequality && (RootContext.WarningLevel > 2)) {
                                        if (container.Methods == null || !container.Methods.HasEquals)
-                                               Report.Warning (660, container.Location, "'{0}' defines operator == or operator != but does not override Object.Equals(object o)", container.GetSignatureForError ());
+                                               Report.Warning (660, 2, container.Location, "`{0}' defines operator == or operator != but does not override Object.Equals(object o)", container.GetSignatureForError ());
  
                                        if (container.Methods == null || !container.Methods.HasGetHashCode)
-                                               Report.Warning (661, container.Location, "'{0}' defines operator == or operator != but does not override Object.GetHashCode()", container.GetSignatureForError ());
+                                               Report.Warning (661, 2, container.Location, "`{0}' defines operator == or operator != but does not override Object.GetHashCode()", container.GetSignatureForError ());
                                }
                        }
 
@@ -448,16 +442,20 @@ namespace Mono.CSharp {
                protected Constructor default_static_constructor;
 
                //
-               // Whether we have at least one non-static field
+               // Points to the first non-static field added to the container.
                //
-               bool have_nonstatic_fields = false;
-               
+               // This is an arbitrary choice.  We are interested in looking at _some_ non-static field,
+               // and the first one's as good as any.
+               //
+               FieldBase first_nonstatic_field = null;
+
                //
                // This one is computed after we can distinguish interfaces
                // from classes from the arraylist `type_bases' 
                //
-               string     base_class_name;
+               string base_class_name;
                TypeExpr base_type;
+               TypeExpr[] iface_exprs;
 
                ArrayList type_bases;
 
@@ -465,7 +463,7 @@ namespace Mono.CSharp {
                bool members_defined_ok;
 
                // The interfaces we implement.
-               protected Type [] ifaces;
+               protected Type[] ifaces;
                protected Type ptype;
 
                // The base member cache and our member cache
@@ -474,12 +472,9 @@ namespace Mono.CSharp {
 
                public const string DefaultIndexerName = "Item";
 
-               // This is used to catch recursive definitions in declarations.
-               protected bool InTransit;
-               
                public TypeContainer (NamespaceEntry ns, TypeContainer parent, MemberName name,
-                                     Attributes attrs, Kind kind, Location l)
-                       : base (ns, parent, name, attrs, l)
+                                     Attributes attrs, Kind kind)
+                       : base (ns, parent, name, attrs)
                {
                        if (parent != null && parent != RootContext.Tree.Types && parent.NamespaceEntry != ns)
                                throw new InternalErrorException ("A nested type should be in the same NamespaceEntry as its enclosing class");
@@ -496,10 +491,9 @@ namespace Mono.CSharp {
                        return AddToContainer (symbol, symbol.Name);
                }
 
-               bool AddToTypeContainer (DeclSpace ds)
+               protected virtual bool AddToTypeContainer (DeclSpace ds)
                {
-                       // Parent == null ==> this == RootContext.Tree.Types
-                       return AddToContainer (ds, (Parent == null) ? ds.Name : ds.Basename);
+                       return AddToContainer (ds, ds.Basename);
                }
 
                public void AddConstant (Const constant)
@@ -524,12 +518,13 @@ namespace Mono.CSharp {
                        enums.Add (e);
                }
                
-               public void AddClassOrStruct (TypeContainer c)
+               public bool AddClassOrStruct (TypeContainer c)
                {
                        if (!AddToTypeContainer (c))
-                               return;
+                               return false;
 
                        types.Add (c);
+                       return true;
                }
 
                public void AddDelegate (Delegate d)
@@ -568,7 +563,7 @@ namespace Mono.CSharp {
                        if (is_static){
                                if (default_static_constructor != null) {
                                        Report.SymbolRelatedToPreviousError (default_static_constructor);
-                                       Report.Error (111, c.Location, Error111, Name, c.Name);
+                                       Report.Error (111, c.Location, Error111, c.GetSignatureForError ());
                                        return;
                                }
 
@@ -577,7 +572,7 @@ namespace Mono.CSharp {
                                if (c.IsDefault ()){
                                        if (default_constructor != null) {
                                                Report.SymbolRelatedToPreviousError (default_constructor);
-                                               Report.Error (111, c.Location, Error111, c.Location, Name, c.Name);
+                                               Report.Error (111, c.Location, Error111, c.GetSignatureForError ());
                                                return;
                                        }
                                        default_constructor = c;
@@ -592,20 +587,21 @@ namespace Mono.CSharp {
 
                internal static string Error111 {
                        get {
-                               return "Type '{0}' already defines a member called '{1}' with the same parameter types";
+                               return "`{0}' is already defined. Rename this member or use different parameter types";
                        }
                }
                
-               public void AddInterface (TypeContainer iface)
+               public bool AddInterface (TypeContainer iface)
                {
                        if (!AddToTypeContainer (iface))
-                               return;
+                               return false;
 
                        if (interfaces == null) {
                                interfaces = new MemberCoreArrayList ();
                        }
 
                        interfaces.Add (iface);
+                       return true;
                }
 
                public void AddField (FieldMember field)
@@ -615,25 +611,25 @@ namespace Mono.CSharp {
 
                        if (fields == null)
                                fields = new MemberCoreArrayList ();
-                       
+
                        fields.Add (field);
 
-                       if (field.HasInitializer){
-                               if ((field.ModFlags & Modifiers.STATIC) != 0){
-                                       if (initialized_static_fields == null)
-                                               initialized_static_fields = new ArrayList ();
-                       
-                                       initialized_static_fields.Add (field);
-                               } else {
-                                       if (initialized_fields == null)
-                                               initialized_fields = new ArrayList ();
-                                                       
-                                       initialized_fields.Add (field);
-                               }
+                       if ((field.ModFlags & Modifiers.STATIC) != 0)
+                               return;
+
+                       if (first_nonstatic_field == null) {
+                               first_nonstatic_field = field;
+                               return;
+                       }
+
+                       if (Kind == Kind.Struct &&
+                           first_nonstatic_field.Parent != field.Parent &&
+                           RootContext.WarningLevel >= 3) {
+                               Report.SymbolRelatedToPreviousError (first_nonstatic_field.Parent);
+                               Report.Warning (282, 3, field.Location,
+                                       "struct instance field `{0}' found in different declaration from instance field `{1}'",
+                                       field.GetSignatureForError (), first_nonstatic_field.GetSignatureForError ());
                        }
-                       
-                       if ((field.ModFlags & Modifiers.STATIC) == 0)
-                               have_nonstatic_fields = true;
                }
 
                public void AddProperty (Property prop)
@@ -721,9 +717,7 @@ namespace Mono.CSharp {
                {
                        if (a.Type == TypeManager.default_member_type) {
                                if (Indexers != null) {
-                                       Report.Error (646, a.Location,
-                                                     "Cannot specify the DefaultMember attribute on" +
-                                                     " a type containing an indexer");
+                                       Report.Error (646, a.Location, "Cannot specify the `DefaultMember' attribute on type containing an indexer");
                                        return;
                                }
                        }
@@ -846,9 +840,9 @@ namespace Mono.CSharp {
                        }
                }
 
-               public virtual TypeAttributes TypeAttr {
+               protected override TypeAttributes TypeAttr {
                        get {
-                               return Modifiers.TypeAttr (ModFlags, this);
+                               return Modifiers.TypeAttr (ModFlags, this) | base.TypeAttr;
                        }
                }
 
@@ -858,48 +852,49 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool IsComImport {
+                       get {
+                               if (OptAttributes == null)
+                                       return false;
+
+                               return OptAttributes.Contains (TypeManager.comimport_attr_type, EmitContext);
+                       }
+               }
+
+               public virtual void RegisterFieldForInitialization (FieldBase field)
+               {
+                       if ((field.ModFlags & Modifiers.STATIC) != 0){
+                               if (initialized_static_fields == null)
+                                       initialized_static_fields = new ArrayList (4);
+
+                               initialized_static_fields.Add (field);
+                       } else {
+                               if (initialized_fields == null)
+                                       initialized_fields = new ArrayList (4);
+
+                               initialized_fields.Add (field);
+                       }
+               }
+
                //
                // Emits the instance field initializers
                //
                public virtual bool EmitFieldInitializers (EmitContext ec)
                {
                        ArrayList fields;
-                       Expression instance_expr;
                        
                        if (ec.IsStatic){
                                fields = initialized_static_fields;
-                               instance_expr = null;
                        } else {
                                fields = initialized_fields;
-                               instance_expr = new This (Location.Null).Resolve (ec);
                        }
 
                        if (fields == null)
                                return true;
 
-                       foreach (Field f in fields){
-                               Expression e = f.GetInitializerExpression (ec);
-                               if (e == null)
-                                       return false;
-
-                               Location l = f.Location;
-                               FieldExpr fe = new FieldExpr (f.FieldBuilder, l);
-                               fe.InstanceExpression = instance_expr;
-                               ExpressionStatement a = new Assign (fe, e, l);
-
-                               a = a.ResolveStatement (ec);
-                               if (a == null)
-                                       return false;
-
-                               Constant c = e as Constant;
-                               if (c != null) {
-                                       if (c.IsDefaultValue)
-                                               continue;
-                               }
-
-                               a.EmitStatement (ec);
+                       foreach (FieldBase f in fields) {
+                               f.EmitInitializer (ec);
                        }
-
                        return true;
                }
                
@@ -926,9 +921,7 @@ namespace Mono.CSharp {
 
                        c = new Constructor (constructor_parent, Basename, mods,
                                             Parameters.EmptyReadOnlyParameters,
-                                            new ConstructorBaseInitializer (
-                                                    null, Parameters.EmptyReadOnlyParameters,
-                                                    Location),
+                                            new GeneratedBaseInitializer (Location),
                                             Location);
                        
                        AddConstructor (c);
@@ -950,32 +943,28 @@ namespace Mono.CSharp {
                        ArrayList ifaces = new ArrayList ();
 
                        base_class = null;
-                       Location base_loc = Location.Null;
 
                        foreach (ClassPart part in parts) {
                                TypeExpr new_base_class;
                                TypeExpr[] new_ifaces;
 
                                new_ifaces = part.GetClassBases (out new_base_class);
-                               if (new_ifaces == null && base_type != null)
+                               if (new_ifaces == null && new_base_class != null)
                                        return null;
 
                                if ((base_class != null) && (new_base_class != null) &&
                                    !base_class.Equals (new_base_class)) {
+                                       Report.SymbolRelatedToPreviousError (base_class.Location, "");
                                        Report.Error (263, part.Location,
                                                      "Partial declarations of `{0}' must " +
                                                      "not specify different base classes",
                                                      Name);
 
-                                       if (!Location.IsNull (base_loc))
-                                               Report.LocationOfPreviousError (base_loc);
-
                                        return null;
                                }
 
                                if ((base_class == null) && (new_base_class != null)) {
                                        base_class = new_base_class;
-                                       base_loc = part.Location;
                                }
 
                                if (new_ifaces == null)
@@ -1074,23 +1063,24 @@ namespace Mono.CSharp {
                                if (base_class.IsSealed){
                                        Report.SymbolRelatedToPreviousError (base_class.Type);
                                        if (base_class.Type.IsAbstract) {
-                                               Report.Error (709, Location, "'{0}': Cannot derive from static class", GetSignatureForError ());
+                                               Report.Error (709, Location, "`{0}': Cannot derive from static class `{1}'",
+                                                       GetSignatureForError (), TypeManager.CSharpName (base_class.Type));
                                        } else {
-                                               Report.Error (509, Location, "'{0}': Cannot derive from sealed class", GetSignatureForError ());
+                                               Report.Error (509, Location, "`{0}': cannot derive from sealed class `{1}'",
+                                                       GetSignatureForError (), TypeManager.CSharpName (base_class.Type));
                                        }
                                        return null;
                                }
 
                                if (!base_class.CanInheritFrom ()){
-                                       Report.Error (644, Location,
-                                                     "`{0}' cannot inherit from special class `{1}'",
-                                                     Name, base_class.Name);
+                                       Report.Error (644, Location, "`{0}' cannot derive from special class `{1}'",
+                                                     GetSignatureForError (), base_class.GetSignatureForError ());
                                        return null;
                                }
 
                                if (!base_class.AsAccessible (this, ModFlags)) {
                                        Report.SymbolRelatedToPreviousError (base_class.Type);
-                                       Report.Error (60, Location, "Inconsistent accessibility: base class '{0}' is less accessible than class '{1}'", 
+                                       Report.Error (60, Location, "Inconsistent accessibility: base class `{0}' is less accessible than class `{1}'", 
                                                TypeManager.CSharpName (base_class.Type), GetSignatureForError ());
                                }
                        }
@@ -1112,13 +1102,11 @@ namespace Mono.CSharp {
                                                Error_TypeInListIsNotInterface (Location, iface.FullName);
                                        }
                                        else if (base_class != null)
-                                               Report.Error (1721, Location,
-                                                             "In Class `{0}', `{1}' is not an interface, and a base class has already been defined",
-                                                             Name, iface.Name);
+                                               Report.Error (1721, Location, "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')",
+                                                       GetSignatureForError (), base_class.GetSignatureForError (), iface.GetSignatureForError ());
                                        else {
-                                               Report.Error (1722, Location,
-                                                             "In Class `{0}', `{1}' is not " +
-                                                             "an interface, a base class must be listed first", Name, iface.Name);
+                                               Report.Error (1722, Location, "`{0}': Base class `{1}' must be specified as first",
+                                                       GetSignatureForError (), iface.GetSignatureForError ());
                                        }
                                        return null;
                                }
@@ -1145,9 +1133,11 @@ namespace Mono.CSharp {
                        return ifaces;
                }
 
+               bool error = false;
+               
                protected void Error_TypeInListIsNotInterface (Location loc, string type)
                {
-                       Report.Error (527, loc, "'{0}': type in interface list is not an interface", type);
+                       Report.Error (527, loc, "Type `{0}' in interface list is not an interface", type);
                }
 
                //
@@ -1155,17 +1145,79 @@ namespace Mono.CSharp {
                //
                public override TypeBuilder DefineType ()
                {
+                       if (error)
+                               return null;
+
                        if (TypeBuilder != null)
                                return TypeBuilder;
                        
-                       InTransit = true;
+                       TypeAttributes type_attributes = TypeAttr;
+
+                       try {
+                               if (IsTopLevel){
+                                       if (TypeManager.NamespaceClash (Name, Location)) {
+                                               error = true;
+                                               return null;
+                                       }
+
+                                       ModuleBuilder builder = CodeGen.Module.Builder;
+                                       TypeBuilder = builder.DefineType (
+                                               Name, type_attributes, null, null);
+                               } else {
+                                       TypeBuilder builder = Parent.TypeBuilder;
+                                       if (builder == null) {
+                                               error = true;
+                                               return null;
+                                       }
+
+                                       TypeBuilder = builder.DefineNestedType (
+                                               Basename, type_attributes, ptype, null);
+                               }
+                       } catch (ArgumentException) {
+                               Report.RuntimeMissingSupport (Location, "static classes");
+                               error = true;
+                               return null;
+                       }
+
+                       TypeManager.AddUserType (this);
 
-                       TypeExpr[] iface_exprs = GetClassBases (out base_type);
+                       if (Parts != null) {
+                               ec = null;
+                               foreach (ClassPart part in Parts) {
+                                       part.TypeBuilder = TypeBuilder;
+                                       part.ec = new EmitContext (part, Mono.CSharp.Location.Null, null, null, ModFlags);
+                                       part.ec.ContainerType = TypeBuilder;
+                               }
+                       } else {
+                               //
+                               // Normally, we create the EmitContext here.
+                               // The only exception is if we're an Iterator - in this case,
+                               // we already have the `ec', so we don't want to create a new one.
+                               //
+                               if (ec == null)
+                                       ec = new EmitContext (this, Mono.CSharp.Location.Null, null, null, ModFlags);
+                               ec.ContainerType = TypeBuilder;
+                       }
+
+                       iface_exprs = GetClassBases (out base_type);
                        if (iface_exprs == null && base_type != null) {
-                               InTransit = false;
+                               error = true;
                                return null;
                        }
 
+                       //
+                       // GetClassBases calls ResolveBaseTypeExpr() on the various type expressions involved,
+                       // which in turn should have called DefineType()s on base types if necessary.
+                       //
+                       // None of the code below should trigger DefineType()s on classes that we depend on.
+                       // Thus, we are eligible to be on the topological sort `type_container_resolve_order'.
+                       //
+                       // Let's do it as soon as possible, since code below can call DefineType() on classes
+                       // that depend on us to be populated before they are.
+                       //
+                       if (!(this is Iterator))
+                               RootContext.RegisterOrder (this); 
+
                        if (base_type == null) {
                                if (Kind == Kind.Class){
                                        if (RootContext.StdLib)
@@ -1188,70 +1240,34 @@ namespace Mono.CSharp {
                        if ((Kind == Kind.Struct) && TypeManager.value_type == null)
                                throw new Exception ();
 
-                       TypeAttributes type_attributes = TypeAttr;
+                       // Avoid attributes check when parent is not set
+                       TypeResolveEmitContext.TestObsoleteMethodUsage = false;
 
                        if (base_type != null) {
                                // FIXME: I think this should be ...ResolveType (Parent.EmitContext).
                                //        However, if Parent == RootContext.Tree.Types, its NamespaceEntry will be null.
                                ptype = base_type.ResolveType (TypeResolveEmitContext);
                                if (ptype == null) {
-                                       InTransit = false;
+                                       error = true;
                                        return null;
                                }
                        }
 
-                       try {
-                               if (IsTopLevel){
-                                       if (TypeManager.NamespaceClash (Name, Location)) {
-                                               InTransit = false;
-                                               return null;
-                                       }
-                               
-                                       ModuleBuilder builder = CodeGen.Module.Builder;
-                                       TypeBuilder = builder.DefineType (
-                                               Name, type_attributes, ptype, null);
-                               
-                               } else {
-                                       TypeBuilder builder = Parent.TypeBuilder;
-                                       if (builder == null) {
-                                               InTransit = false;
-                                               return null;
-                                       }
-                               
-                                       TypeBuilder = builder.DefineNestedType (
-                                               Basename, type_attributes, ptype, null);
-                               }
-                       }
-                       catch (ArgumentException) {
-                               Report.RuntimeMissingSupport (Location, "static classes");
-                               InTransit = false;
+                       if (!CheckRecursiveDefinition (this)) {
+                               error = true;
                                return null;
                        }
 
-                       if (Parts != null) {
-                               ec = null;
-                               foreach (ClassPart part in Parts) {
-                                       part.TypeBuilder = TypeBuilder;
-                                       part.ptype = ptype;
-                                       part.ec = new EmitContext (part, Mono.CSharp.Location.Null, null, null, ModFlags);
-                                       part.ec.ContainerType = TypeBuilder;
-                               }
-                       }
-                       else {
-                               ec = new EmitContext (this, Mono.CSharp.Location.Null, null, null, ModFlags);
-                               ec.ContainerType = TypeBuilder;
+                       if (ptype != null) {
+                               TypeBuilder.SetParent (ptype);
                        }
 
-                       //
-                       // Structs with no fields need to have at least one byte.
-                       // The right thing would be to set the PackingSize in a DefineType
-                       // but there are no functions that allow interfaces *and* the size to
-                       // be specified.
-                       //
-
-                       if ((Kind == Kind.Struct) && !have_nonstatic_fields){
-                               TypeBuilder.DefineField ("$PRIVATE$", TypeManager.byte_type,
-                                                        FieldAttributes.Private);
+                       // Attribute is undefined at the begining of corlib compilation
+                       if (TypeManager.obsolete_attribute_type != null) {
+                               TypeResolveEmitContext.TestObsoleteMethodUsage = GetObsoleteAttribute () == null;
+                               if (ptype != null && TypeResolveEmitContext.TestObsoleteMethodUsage) {
+                                       CheckObsoleteType (base_type);
+                               }
                        }
 
                        // add interfaces that were not added at type creation
@@ -1261,7 +1277,7 @@ namespace Mono.CSharp {
                                TypeResolveEmitContext.ContainerType = TypeBuilder;
                                ifaces = TypeManager.ExpandInterfaces (TypeResolveEmitContext, iface_exprs);
                                if (ifaces == null) {
-                                       InTransit = false;
+                                       error = true;
                                        return null;
                                }
 
@@ -1271,14 +1287,8 @@ namespace Mono.CSharp {
                                TypeManager.RegisterBuilder (TypeBuilder, ifaces);
                        }
 
-                       TypeManager.AddUserType (Name, TypeBuilder, this);
-
-                       if (!(this is Iterator))
-                               RootContext.RegisterOrder (this); 
-
-                       InTransit = false;
-
                        if (!DefineNestedTypes ()) {
+                               error = true;
                                return null;
                        }
 
@@ -1314,42 +1324,85 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               static void Error_KeywordNotAllowed (Location loc)
+               TypeContainer InTransit;
+
+               protected bool CheckRecursiveDefinition (TypeContainer tc)
+               {
+                       if (InTransit != null) {
+                               Report.SymbolRelatedToPreviousError (this);
+                               if (this is Interface)
+                                       Report.Error (
+                                               529, tc.Location, "Inherited interface `{0}' causes a " +
+                                               "cycle in the interface hierarchy of `{1}'",
+                                               GetSignatureForError (), tc.GetSignatureForError ());
+                               else
+                                       Report.Error (
+                                               146, tc.Location, "Circular base class dependency " +
+                                               "involving `{0}' and `{1}'",
+                                               tc.GetSignatureForError (), GetSignatureForError ());
+                               return false;
+                       }
+
+                       InTransit = tc;
+
+                       Type parent = ptype;
+                       if (parent != null) {
+                               TypeContainer ptc = TypeManager.LookupTypeContainer (parent);
+                               if ((ptc != null) && !ptc.CheckRecursiveDefinition (this))
+                                       return false;
+                       }
+
+                       if (iface_exprs != null) {
+                               foreach (TypeExpr iface in iface_exprs) {
+                                       Type itype = iface.Type;
+
+                                       TypeContainer ptc = TypeManager.LookupTypeContainer (itype);
+                                       if ((ptc != null) && !ptc.CheckRecursiveDefinition (this))
+                                               return false;
+                               }
+                       }
+
+                       InTransit = null;
+                       return true;
+               }
+
+               public static void Error_KeywordNotAllowed (Location loc)
                {
-                       Report.Error (1530, loc, "Keyword new not allowed for namespace elements");
+                       Report.Error (1530, loc, "Keyword `new' is not allowed on namespace elements");
                }
 
                /// <summary>
                ///   Populates our TypeBuilder with fields and methods
                /// </summary>
-               public override bool DefineMembers (TypeContainer container)
+               public override bool DefineMembers ()
                {
                        if (members_defined)
                                return members_defined_ok;
 
+                       if (!base.DefineMembers ())
+                               return false;
+
                        members_defined_ok = DoDefineMembers ();
                        members_defined = true;
 
                        return members_defined_ok;
                }
 
-               bool DoDefineMembers ()
-               {
-                       if (IsTopLevel) {
-                               if ((ModFlags & Modifiers.NEW) != 0)
-                                       Error_KeywordNotAllowed (Location);
-                       } else {
-                               MemberInfo conflict_symbol = Parent.MemberCache.FindMemberWithSameName (Basename, false, TypeBuilder);
-                               if (conflict_symbol == null) {
-                                       if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0))
-                                               Report.Warning (109, Location, "The member '{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
-                               } else {
-                                       if ((ModFlags & Modifiers.NEW) == 0) {
-                                               Report.SymbolRelatedToPreviousError (conflict_symbol);
-                                               Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError ());
-                                       }
-                               }
-                       }
+               protected virtual bool DoDefineMembers ()
+               {
+                       if (!IsTopLevel) {
+                               MemberInfo conflict_symbol = Parent.MemberCache.FindMemberWithSameName (Basename, false, TypeBuilder);
+                               if (conflict_symbol == null) {
+                                       if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0))
+                                               Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
+                               } else {
+                                       if ((ModFlags & Modifiers.NEW) == 0) {
+                                               Report.SymbolRelatedToPreviousError (conflict_symbol);
+                                               Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                                                       GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
+                                       }
+                               }
+                       }
 
                        DefineContainerMembers (constants);
                        DefineContainerMembers (fields);
@@ -1383,7 +1436,7 @@ namespace Mono.CSharp {
 
                        if (parts != null) {
                                foreach (ClassPart part in parts) {
-                                       if (!part.DefineMembers (this))
+                                       if (!part.DefineMembers ())
                                                return false;
                                }
                        }
@@ -1421,7 +1474,7 @@ namespace Mono.CSharp {
                                }
 
                                foreach (Iterator iterator in iterators) {
-                                       if (!iterator.DefineMembers (this))
+                                       if (!iterator.DefineMembers ())
                                                return false;
                                }
                        }
@@ -1431,13 +1484,10 @@ namespace Mono.CSharp {
 
                void ReportStructInitializedInstanceError ()
                {
-                       string n = TypeBuilder.FullName;
-                       
                        foreach (Field f in initialized_fields){
-                               Report.Error (
-                                       573, Location,
-                                       "`" + n + "." + f.Name + "': can not have " +
-                                       "instance field initializers in structs");
+                               Report.Error (573, Location,
+                                       "`{0}': Structs cannot have instance field initializers",
+                                       f.GetSignatureForError ());
                        }
                }
 
@@ -1456,6 +1506,13 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       if (iterators != null) {
+                               foreach (Iterator iterator in iterators) {
+                                       if (!iterator.Define ())
+                                               return false;
+                               }
+                       }
+
                        return true;
                }
 
@@ -1488,7 +1545,7 @@ namespace Mono.CSharp {
                {
                        ArrayList members = new ArrayList ();
 
-                       DefineMembers (null);
+                       DefineMembers ();
 
                        if (methods != null) {
                                int len = methods.Count;
@@ -1992,7 +2049,7 @@ namespace Mono.CSharp {
                                        continue;
 
                                if (!mc.IsUsed) {
-                                       Report.Warning (169, mc.Location, "The private {0} '{1}' is never used", member_type, mc.GetSignatureForError ());
+                                       Report.Warning (169, 3, mc.Location, "The private {0} `{1}' is never used", member_type, mc.GetSignatureForError ());
                                }
                        }
                }
@@ -2013,7 +2070,17 @@ namespace Mono.CSharp {
                                                        continue;
                                                
                                                if (!f.IsUsed){
-                                                       Report.Warning (169, f.Location, "The private field '{0}' is never used", f.GetSignatureForError ());
+                                                       if ((f.caching_flags & Flags.IsAssigned) == 0)
+                                                               Report.Warning (169, 3, f.Location, "The private field `{0}' is never used", f.GetSignatureForError ());
+                                                       else {
+#if NET_2_0
+                                                               const int error_code = 414;
+#else
+                                                               const int error_code = 169;
+#endif
+                                                               Report.Warning (error_code, 3, f.Location, "The private field `{0}' is assigned but its value is never used",
+                                                                       f.GetSignatureForError ());
+                                                       }
                                                        continue;
                                                }
                                                
@@ -2023,10 +2090,11 @@ namespace Mono.CSharp {
                                                if (RootContext.WarningLevel < 4)
                                                        continue;
                                                
-                                               if ((f.status & Field.Status.ASSIGNED) != 0)
+                                               if ((f.caching_flags & Flags.IsAssigned) != 0)
                                                        continue;
                                                
-                                               Report.Warning (649, f.Location, "Field '{0}' is never assigned to, and will always have its default value '{1}'", f.GetSignatureForError (), "");
+                                               Report.Warning (649, 4, f.Location, "Field `{0}' is never assigned to, and will always have its default value `{1}'",
+                                                       f.GetSignatureForError (), f.Type.Type.IsValueType ? Activator.CreateInstance (f.Type.Type).ToString() : "null");
                                        }
                                }
                        }
@@ -2036,15 +2104,36 @@ namespace Mono.CSharp {
                ///   Emits the code, this step is performed after all
                ///   the types, enumerations, constructors
                /// </summary>
-               public void EmitType ()
+               public virtual void EmitType ()
                {
                        if (OptAttributes != null)
                                OptAttributes.Emit (ec, this);
                                
+                       //
+                       // Structs with no fields need to have at least one byte.
+                       // The right thing would be to set the PackingSize in a DefineType
+                       // but there are no functions that allow interfaces *and* the size to
+                       // be specified.
+                       //
+
+                       if (Kind == Kind.Struct && first_nonstatic_field == null){
+                               FieldBuilder fb = TypeBuilder.DefineField ("$PRIVATE$", TypeManager.byte_type,
+                                                                          FieldAttributes.Private);
+
+                               if (HasExplicitLayout){
+                                       object [] ctor_args = new object [1];
+                                       ctor_args [0] = 0;
+                               
+                                       CustomAttributeBuilder cba = new CustomAttributeBuilder (
+                                               TypeManager.field_offset_attribute_ctor, ctor_args);
+                                       fb.SetCustomAttribute (cba);
+                               }
+                       }
+
                        Emit ();
 
                        if (instance_constructors != null) {
-                               if (TypeBuilder.IsSubclassOf (TypeManager.attribute_type) && RootContext.VerifyClsCompliance && IsClsCompliaceRequired (this)) {
+                               if (TypeBuilder.IsSubclassOf (TypeManager.attribute_type) && RootContext.VerifyClsCompliance && IsClsComplianceRequired (this)) {
                                        bool has_compliant_args = false;
 
                                        foreach (Constructor c in instance_constructors) {
@@ -2056,14 +2145,17 @@ namespace Mono.CSharp {
                                                has_compliant_args = c.HasCompliantArgs;
                                        }
                                        if (!has_compliant_args)
-                                               Report.Error (3015, Location, "'{0}' has no accessible constructors which use only CLS-compliant types", GetSignatureForError ());
+                                               Report.Error (3015, Location, "`{0}' has no accessible constructors which use only CLS-compliant types", GetSignatureForError ());
                                } else {
                                        foreach (Constructor c in instance_constructors)
                                                c.Emit ();
                                }
                        }
 
+                       // Can not continue if constants are broken
                        EmitConstants ();
+                       if (Report.Errors > 0)
+                               return;
 
                        if (default_static_constructor != null)
                                default_static_constructor.Emit ();
@@ -2188,12 +2280,6 @@ namespace Mono.CSharp {
                        member_cache = null;
                }
 
-               // TODO: make it obsolete and use GetSignatureForError
-               public string MakeName (string n)
-               {
-                       return "`" + Name + "." + n + "'";
-               }
-
                //
                // Performs the validation on a Method's modifiers (properties have
                // the same properties).
@@ -2211,8 +2297,8 @@ namespace Mono.CSharp {
                        //
                        if ((flags & Modifiers.STATIC) != 0){
                                if ((flags & vao) != 0){
-                                       Report.Error (112, mc.Location, "static method '{0}' can not be marked as virtual, abstract or override",
-                                               GetSignatureForError ());
+                                       Report.Error (112, mc.Location, "A static member `{0}' cannot be marked as override, virtual or abstract",
+                                               mc.GetSignatureForError ());
                                        ok = false;
                                }
                        }
@@ -2225,7 +2311,8 @@ namespace Mono.CSharp {
                        }
 
                        if ((flags & Modifiers.OVERRIDE) != 0 && (flags & nv) != 0){
-                               Report.Error (113, mc.Location, "'{0}' marked as override cannot be marked as new or virtual", mc.GetSignatureForError ());
+                               Report.Error (113, mc.Location, "A member `{0}' marked as override cannot be marked as new or virtual",
+                                       mc.GetSignatureForError ());
                                ok = false;
                        }
 
@@ -2236,36 +2323,36 @@ namespace Mono.CSharp {
                        if ((flags & Modifiers.ABSTRACT) != 0){
                                if ((flags & Modifiers.EXTERN) != 0){
                                        Report.Error (
-                                               180, mc.Location, "'{0}' can not be both abstract and extern", mc.GetSignatureForError ());
+                                               180, mc.Location, "`{0}' cannot be both extern and abstract", mc.GetSignatureForError ());
                                        ok = false;
                                }
 
                                if ((flags & Modifiers.SEALED) != 0) {
-                                       Report.Error (502, mc.Location, "'{0}' cannot be both abstract and sealed", mc.GetSignatureForError ());
+                                       Report.Error (502, mc.Location, "`{0}' cannot be both abstract and sealed", mc.GetSignatureForError ());
                                        ok = false;
                                }
 
                                if ((flags & Modifiers.VIRTUAL) != 0){
-                                       Report.Error (503, mc.Location, "'{0}' can not be both abstract and virtual", mc.GetSignatureForError ());
+                                       Report.Error (503, mc.Location, "The abstract method `{0}' cannot be marked virtual", mc.GetSignatureForError ());
                                        ok = false;
                                }
 
                                if ((ModFlags & Modifiers.ABSTRACT) == 0){
-                                       Report.Error (513, mc.Location, "'{0}' is abstract but its container class is not", mc.GetSignatureForError ());
+                                       Report.Error (513, mc.Location, "`{0}' is abstract but it is contained in nonabstract class", mc.GetSignatureForError ());
                                        ok = false;
                                }
                        }
 
                        if ((flags & Modifiers.PRIVATE) != 0){
                                if ((flags & vao) != 0){
-                                       Report.Error (621, mc.Location, "'{0}' virtual or abstract members can not be private", mc.GetSignatureForError ());
+                                       Report.Error (621, mc.Location, "`{0}': virtual or abstract members cannot be private", mc.GetSignatureForError ());
                                        ok = false;
                                }
                        }
 
                        if ((flags & Modifiers.SEALED) != 0){
                                if ((flags & Modifiers.OVERRIDE) == 0){
-                                       Report.Error (238, mc.Location, "'{0}' cannot be sealed because it is not an override", mc.GetSignatureForError ());
+                                       Report.Error (238, mc.Location, "`{0}' cannot be sealed because it is not an override", mc.GetSignatureForError ());
                                        ok = false;
                                }
                        }
@@ -2292,11 +2379,11 @@ namespace Mono.CSharp {
 
                        Type base_type = TypeBuilder.BaseType;
                        if (base_type != null && !AttributeTester.IsClsCompliant (base_type)) {
-                               Report.Error (3009, Location, "'{0}': base type '{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (base_type));
+                               Report.Error (3009, Location, "`{0}': base type `{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (base_type));
                        }
 
-                       if (!Parent.IsClsCompliaceRequired (ds)) {
-                               Report.Error (3018, Location, "'{0}' cannot be marked as CLS-Compliant because it is a member of non CLS-Compliant type '{1}'", 
+                       if (!Parent.IsClsComplianceRequired (ds)) {
+                               Report.Error (3018, Location, "`{0}' cannot be marked as CLS-compliant because it is a member of non CLS-compliant type `{1}'", 
                                        GetSignatureForError (), Parent.GetSignatureForError ());
                        }
                        return true;
@@ -2315,10 +2402,10 @@ namespace Mono.CSharp {
 
                        foreach (DictionaryEntry entry in defined_names) {
                                MemberCore mc = (MemberCore)entry.Value;
-                               if (!mc.IsClsCompliaceRequired (this))
+                               if (!mc.IsClsComplianceRequired (mc.Parent))
                                        continue;
 
-                               string name = (string)entry.Key;
+                               string name = (string) entry.Key;
                                string basename = name.Substring (name.LastIndexOf ('.') + 1);
 
                                string lcase = basename.ToLower (System.Globalization.CultureInfo.InvariantCulture);
@@ -2335,13 +2422,13 @@ namespace Mono.CSharp {
                                        continue;                                       
 
                                if (found is MemberInfo) {
-                                       if (basename == ((MemberInfo)found).Name)
+                                       if (basename == ((MemberInfo) found).Name)
                                                continue;
-                                       Report.SymbolRelatedToPreviousError ((MemberInfo)found);
+                                       Report.SymbolRelatedToPreviousError ((MemberInfo) found);
                                } else {
                                        Report.SymbolRelatedToPreviousError ((MemberCore) found);
                                }
-                               Report.Error (3005, mc.Location, "Identifier '{0}' differing only in case is not CLS-compliant", mc.GetSignatureForError ());
+                               Report.Error (3005, mc.Location, "Identifier `{0}' differing only in case is not CLS-compliant", mc.GetSignatureForError ());
                        }
                }
 
@@ -2351,41 +2438,29 @@ namespace Mono.CSharp {
                ///   checks whether the `interface_type' is a base inteface implementation.
                ///   Then it checks whether `name' exists in the interface type.
                /// </summary>
-               public virtual bool VerifyImplements (Type interface_type, string full,
-                                                     string name, Location loc)
+               public virtual bool VerifyImplements (MemberBase mb)
                {
-                       bool found = false;
-
-                       if (ifaces != null){
+                       if (ifaces != null) {
                                foreach (Type t in ifaces){
-                                       if (t == interface_type){
-                                               found = true;
-                                               break;
-                                       }
+                                       if (t == mb.InterfaceType)
+                                               return true;
                                }
                        }
                        
-                       if (!found){
-                               Report.Error (540, loc, "`{0}': containing class does not implement interface `{1}'",
-                                             full, interface_type.FullName);
-                               return false;
-                       }
-
-                       return true;
+                       Report.Error (540, mb.Location, "`{0}': containing type does not implement interface `{1}'",
+                               mb.GetSignatureForError (), TypeManager.CSharpName (mb.InterfaceType));
+                       return false;
                }
 
-               protected override void VerifyObsoleteAttribute()
+               public virtual void Mark_HasEquals ()
                {
-                       CheckUsageOfObsoleteAttribute (ptype);
-
-                       if (ifaces == null)
-                               return;
-
-                       foreach (Type iface in ifaces) {
-                               CheckUsageOfObsoleteAttribute (iface);
-                       }
+                       Methods.HasEquals = true;
                }
 
+               public virtual void Mark_HasGetHashCode ()
+               {
+                       Methods.HasGetHashCode = true;
+               }
 
                //
                // IMemberContainer
@@ -2452,42 +2527,28 @@ namespace Mono.CSharp {
                public readonly int OriginalModFlags;
                public readonly int AllowedModifiers;
                public readonly TypeAttributes DefaultTypeAttributes;
+               public ListDictionary DeclarativeSecurity;
 
                static PartialContainer Create (NamespaceEntry ns, TypeContainer parent,
-                                               MemberName member_name, int mod_flags, Kind kind,
-                                               Location loc)
+                                               MemberName member_name, int mod_flags, Kind kind)
                {
-                       PartialContainer pc;
-                       DeclSpace ds = RootContext.Tree.GetDecl (member_name);
-                       if (ds != null) {
-                               pc = ds as PartialContainer;
-
-                               if (pc == null) {
-                                       Report.Error (
-                                               260, ds.Location, "Missing partial modifier " +
-                                               "on declaration of type `{0}'; another " +
-                                               "partial implementation of this type exists",
-                                               member_name.GetPartialName());
 
-                                       Report.LocationOfPreviousError (loc);
-                                       return null;
-                               }
+                       if (!CheckModFlags (0, mod_flags, member_name))
+                               return null;
 
+                       PartialContainer pc = RootContext.Tree.GetDecl (member_name) as PartialContainer;
+                       if (pc != null) {
                                if (pc.Kind != kind) {
                                        Report.Error (
-                                               261, loc, "Partial declarations of `{0}' " +
+                                               261, member_name.Location, "Partial declarations of `{0}' " +
                                                "must be all classes, all structs or " +
                                                "all interfaces", member_name.GetPartialName ());
                                        return null;
                                }
 
-                               if (pc.OriginalModFlags != mod_flags) {
-                                       Report.Error (
-                                               262, loc, "Partial declarations of `{0}' " +
-                                               "have conflicting accessibility modifiers",
-                                               member_name.GetPartialName ());
+                               if (!CheckModFlags (pc.OriginalModFlags, mod_flags, member_name))
                                        return null;
-                               }
+                               pc.ModFlags |= (mod_flags & pc.AllowedModifiers);
 
                                return pc;
                        }
@@ -2495,38 +2556,70 @@ namespace Mono.CSharp {
                        if (parent is ClassPart)
                                parent = ((ClassPart) parent).PartialContainer;
 
-                       pc = new PartialContainer (ns.NS, parent, member_name, mod_flags, kind, loc);
-                       RootContext.Tree.RecordDecl (member_name, pc);
+                       pc = new PartialContainer (ns.NS, parent, member_name, mod_flags, kind);
 
-                       if (kind == Kind.Interface)
-                               parent.AddInterface (pc);
-                       else if (kind == Kind.Class || kind == Kind.Struct)
-                               parent.AddClassOrStruct (pc);
-                       else
+                       if (kind == Kind.Interface) {
+                               if (!parent.AddInterface (pc))
+                                       return null;
+                       } else if (kind == Kind.Class || kind == Kind.Struct) {
+                               if (!parent.AddClassOrStruct (pc))
+                                       return null;
+                       } else {
                                throw new InvalidOperationException ();
-
+                       }
+                       RootContext.Tree.RecordDecl (ns.NS, member_name, pc);
                        return pc;
                }
 
+               static bool CheckModFlags (int flags_org, int flags, MemberName member_name)
+               {
+                       // Check (abstract|static|sealed) sanity.
+                       int tmp = (flags_org | flags) & (Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC);
+                       if ((tmp & Modifiers.ABSTRACT) != 0) {
+                               if ((tmp & (Modifiers.STATIC | Modifiers.SEALED)) != 0) {
+                                       Report.Error (
+                                               418, member_name.Location, 
+                                               "`{0}': an abstract class cannot be sealed or static", member_name.ToString ());
+                                       return false;
+                               }
+                       } else if (tmp == (Modifiers.SEALED | Modifiers.STATIC)) {
+                               Report.Error (441, member_name.Location, "`{0}': a class cannot be both static and sealed", member_name.ToString ());
+                               return false;
+                       }
+
+                       if (flags_org == 0)
+                               return true;
+
+                       // Check conflicts.
+                       if (0 != ((flags_org ^ flags) & (0xFFFFFFFF ^ (Modifiers.SEALED | Modifiers.ABSTRACT)))) {
+                               Report.Error (
+                                       262, member_name.Location, "Partial declarations of `{0}' " +
+                                       "have conflicting accessibility modifiers",
+                                       member_name.GetPartialName ());
+                               return false;
+                       }
+                       return true;
+               }
+
                public static ClassPart CreatePart (NamespaceEntry ns, TypeContainer parent,
                                                    MemberName name, int mod, Attributes attrs,
                                                    Kind kind, Location loc)
                {
-                       PartialContainer pc = Create (ns, parent, name, mod, kind, loc);
+                       PartialContainer pc = Create (ns, parent, name, mod, kind);
                        if (pc == null) {
                                // An error occured; create a dummy container, but don't
                                // register it.
-                               pc = new PartialContainer (ns.NS, parent, name, mod, kind, loc);
+                               pc = new PartialContainer (ns.NS, parent, name, mod, kind);
                        }
 
-                       ClassPart part = new ClassPart (ns, pc, parent, mod, attrs, kind, loc);
+                       ClassPart part = new ClassPart (ns, pc, parent, mod, attrs, kind);
                        pc.AddPart (part);
                        return part;
                }
 
                protected PartialContainer (Namespace ns, TypeContainer parent,
-                                           MemberName name, int mod, Kind kind, Location l)
-                       : base (null, parent, name, null, kind, l)
+                                           MemberName name, int mod, Kind kind)
+                       : base (null, parent, name, null, kind)
                {
                        this.Namespace = ns;
 
@@ -2556,18 +2649,34 @@ namespace Mono.CSharp {
                        else
                                accmods = Modifiers.PRIVATE;
 
-                       this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
+                       this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, Location);
                        this.OriginalModFlags = mod;
                }
 
-               public override PendingImplementation GetPendingImplementations ()
+               public override void EmitType ()
                {
-                       return PendingImplementation.GetPendingImplementations (this);
-               }
+                       base.EmitType ();
 
-               public override TypeAttributes TypeAttr {
-                       get {
-                               return base.TypeAttr | DefaultTypeAttributes;
+                       if (DeclarativeSecurity != null) {
+                               foreach (DictionaryEntry de in DeclarativeSecurity) {
+                                       TypeBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
+                               }
+                       }
+               }
+
+               public override PendingImplementation GetPendingImplementations ()
+               {
+                       return PendingImplementation.GetPendingImplementations (this);
+               }
+
+               public override bool MarkForDuplicationCheck ()
+               {
+                       return true;
+               }
+
+               protected override TypeAttributes TypeAttr {
+                       get {
+                               return base.TypeAttr | DefaultTypeAttributes;
                        }
                }
        }
@@ -2577,8 +2686,8 @@ namespace Mono.CSharp {
                public readonly bool IsPartial;
 
                public ClassPart (NamespaceEntry ns, PartialContainer pc, TypeContainer parent,
-                                 int mod, Attributes attrs, Kind kind, Location l)
-                       : base (ns, parent, pc.MemberName, attrs, kind, l)
+                                 int mod, Attributes attrs, Kind kind)
+                       : base (ns, parent, pc.MemberName, attrs, kind)
                {
                        this.PartialContainer = pc;
                        this.IsPartial = true;
@@ -2589,7 +2698,20 @@ namespace Mono.CSharp {
                        else
                                accmods = Modifiers.PRIVATE;
 
-                       this.ModFlags = Modifiers.Check (pc.AllowedModifiers, mod, accmods, l);
+                       this.ModFlags = Modifiers.Check (pc.AllowedModifiers, mod, accmods, pc.MemberName.Location);
+               }
+
+               public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
+               {
+                       if (a.Type.IsSubclassOf (TypeManager.security_attr_type) && a.CheckSecurityActionValidity (false)) {
+                               if (PartialContainer.DeclarativeSecurity == null)
+                                       PartialContainer.DeclarativeSecurity = new ListDictionary ();
+
+                               a.ExtractSecurityPermissionSet (PartialContainer.DeclarativeSecurity);
+                               return;
+                       }
+
+                       base.ApplyAttributeBuilder (a, cb);
                }
 
                public override PendingImplementation GetPendingImplementations ()
@@ -2597,11 +2719,15 @@ namespace Mono.CSharp {
                        return PartialContainer.Pending;
                }
 
-               public override bool VerifyImplements (Type interface_type, string full,
-                                                      string name, Location loc)
+               public override bool VerifyImplements (MemberBase mb)
+               {
+                       return PartialContainer.VerifyImplements (mb);
+               }
+
+
+               public override void RegisterFieldForInitialization (FieldBase field)
                {
-                       return PartialContainer.VerifyImplements (
-                               interface_type, full, name, loc);
+                       PartialContainer.RegisterFieldForInitialization (field);
                }
 
                public override bool EmitFieldInitializers (EmitContext ec)
@@ -2619,16 +2745,30 @@ namespace Mono.CSharp {
                                return PartialContainer.BaseCache;
                        }
                }
+
+               public override TypeBuilder DefineType ()
+               {
+                       throw new InternalErrorException ("Should not get here");
+               }
+
+               public override void Mark_HasEquals ()
+               {
+                       PartialContainer.Mark_HasEquals ();
+               }
+
+               public override void Mark_HasGetHashCode ()
+               {
+                       PartialContainer.Mark_HasGetHashCode ();
+               }
        }
 
        public abstract class ClassOrStruct : TypeContainer {
-               bool hasExplicitLayout = false;
+               bool has_explicit_layout = false;
                ListDictionary declarative_security;
 
                public ClassOrStruct (NamespaceEntry ns, TypeContainer parent,
-                                     MemberName name, Attributes attrs, Kind kind,
-                                     Location l)
-                       : base (ns, parent, name, attrs, kind, l)
+                                     MemberName name, Attributes attrs, Kind kind)
+                       : base (ns, parent, name, attrs, kind)
                {
                }
 
@@ -2639,7 +2779,7 @@ namespace Mono.CSharp {
 
                public override bool HasExplicitLayout {
                        get {
-                               return hasExplicitLayout;
+                               return has_explicit_layout;
                        }
                }
 
@@ -2649,8 +2789,8 @@ namespace Mono.CSharp {
 
                        if ((events != null) && (RootContext.WarningLevel >= 3)) {
                                foreach (Event e in events){
-                                       if (e.status == 0)
-                                               Report.Warning (67, e.Location, "The event '{0}' is never used", e.GetSignatureForError ());
+                                       if ((e.caching_flags & Flags.IsAssigned) == 0)
+                                               Report.Warning (67, 3, e.Location, "The event `{0}' is never used", e.GetSignatureForError ());
                                }
                        }
                }
@@ -2665,9 +2805,8 @@ namespace Mono.CSharp {
                                return;
                        }
 
-                       if (a.Type == TypeManager.struct_layout_attribute_type &&
-                           a.GetLayoutKindValue () == LayoutKind.Explicit)
-                               hasExplicitLayout = true;
+                       if (a.Type == TypeManager.struct_layout_attribute_type && a.GetLayoutKindValue () == LayoutKind.Explicit)
+                               has_explicit_layout = true;
 
                        base.ApplyAttributeBuilder (a, cb);
                }
@@ -2689,11 +2828,11 @@ namespace Mono.CSharp {
        /// </summary>
        public sealed class StaticClass: Class {
                public StaticClass (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
-                       Attributes attrs, Location l)
-                       : base (ns, parent, name, mod, attrs, l)
+                       Attributes attrs)
+                       : base (ns, parent, name, mod, attrs)
                {
                        if (RootContext.Version == LanguageVersion.ISO_1) {
-                               Report.FeatureIsNotStandardized (l, "static classes");
+                               Report.FeatureIsNotStandardized (Location, "static classes");
                        }
                }
 
@@ -2711,15 +2850,22 @@ namespace Mono.CSharp {
 
                        foreach (MemberCore m in list) {
                                if (m is Operator) {
-                                       Report.Error (715, m.Location, "'{0}': static classes cannot contain user-defined operators", m.GetSignatureForError (this));
+                                       Report.Error (715, m.Location, "`{0}': Static classes cannot contain user-defined operators", m.GetSignatureForError ());
+                                       continue;
+                               }
+
+                               if (m is Destructor) {
+                                       Report.Error (711, m.Location, "`{0}': Static classes cannot contain destructor", GetSignatureForError ());
                                        continue;
                                }
 
-                               if ((m.ModFlags & Modifiers.PROTECTED) != 0)
-                                       Report.Warning (628, 4, m.Location, "'{0}': new protected member declared in static class", m.GetSignatureForError (this));
+                               if ((m.ModFlags & Modifiers.PROTECTED) != 0) {
+                                       Report.Error (1057, m.Location, "`{0}': Static classes cannot contain protected members", m.GetSignatureForError ());
+                                       continue;
+                               }
 
                                if (m is Indexer) {
-                                       Report.Error (720, m.Location, "'{0}': cannot declare indexers in a static class", m.GetSignatureForError (this));
+                                       Report.Error (720, m.Location, "`{0}': cannot declare indexers in a static class", m.GetSignatureForError ());
                                        continue;
                                }
 
@@ -2727,16 +2873,11 @@ namespace Mono.CSharp {
                                        continue;
 
                                if (m is Constructor) {
-                                       Report.Error (710, m.Location, "'{0}': Static classes cannot have instance constructors", GetSignatureForError ());
-                                       continue;
-                               }
-
-                               if (m is Destructor) {
-                                       Report.Error (711, m.Location, "'{0}': Static class cannot contain destructor", GetSignatureForError ());
+                                       Report.Error (710, m.Location, "`{0}': Static classes cannot have instance constructors", GetSignatureForError ());
                                        continue;
                                }
 
-                               Report.Error (708, m.Location, "'{0}': cannot declare instance members in a static class", m.GetSignatureForError (this));
+                               Report.Error (708, m.Location, "`{0}': cannot declare instance members in a static class", m.GetSignatureForError ());
                        }
 
                        base.DefineContainerMembers (list);
@@ -2745,7 +2886,7 @@ namespace Mono.CSharp {
                public override TypeBuilder DefineType()
                {
                        if ((ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) == (Modifiers.SEALED | Modifiers.STATIC)) {
-                               Report.Error (441, Location, "'{0}': a class cannot be both static and sealed", GetSignatureForError ());
+                               Report.Error (441, Location, "`{0}': a class cannot be both static and sealed", GetSignatureForError ());
                                return null;
                        }
 
@@ -2754,19 +2895,19 @@ namespace Mono.CSharp {
                                return null;
 
                        if (ptype != TypeManager.object_type) {
-                               Report.Error (713, Location, "Static class '{0}' cannot derive from type '{1}'. Static classes must derive from object", GetSignatureForError (), TypeManager.CSharpName (ptype));
+                               Report.Error (713, Location, "Static class `{0}' cannot derive from type `{1}'. Static classes must derive from object", GetSignatureForError (), TypeManager.CSharpName (ptype));
                                return null;
                        }
 
                        if (ifaces != null) {
                                foreach (Type t in ifaces)
                                        Report.SymbolRelatedToPreviousError (t);
-                               Report.Error (714, Location, "'{0}': static classes cannot implement interfaces", GetSignatureForError ());
+                               Report.Error (714, Location, "`{0}': static classes cannot implement interfaces", GetSignatureForError ());
                        }
                        return tb;
                }
 
-               public override TypeAttributes TypeAttr {
+               protected override TypeAttributes TypeAttr {
                        get {
                                return base.TypeAttr | TypeAttributes.Abstract | TypeAttributes.Sealed;
                        }
@@ -2785,11 +2926,9 @@ namespace Mono.CSharp {
                        Modifiers.SEALED |
                        Modifiers.UNSAFE;
 
-               bool WasTransitError;
-
                public Class (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
-                             Attributes attrs, Location l)
-                       : base (ns, parent, name, attrs, Kind.Class, l)
+                             Attributes attrs)
+                       : base (ns, parent, name, attrs, Kind.Class)
                {
                        this.ModFlags = mod;
                }
@@ -2805,7 +2944,7 @@ namespace Mono.CSharp {
                        if (a.Type == TypeManager.attribute_usage_type) {
                                if (ptype != TypeManager.attribute_type && !ptype.IsSubclassOf (TypeManager.attribute_type) &&
                                        TypeBuilder.FullName != "System.Attribute") {
-                                       Report.Error (641, a.Location, "Attribute '{0}' is only valid on classes derived from System.Attribute", a.Name);
+                                       Report.Error (641, a.Location, "Attribute `{0}' is only valid on classes derived from System.Attribute", a.GetSignatureForError ());
                                }
                        }
 
@@ -2826,30 +2965,15 @@ namespace Mono.CSharp {
 
                public override TypeBuilder DefineType()
                {
-                       if (InTransit) {
-                               if (WasTransitError)
-                                       return null;
-                               throw new CircularDepException (this);
-                       }
-
                        if ((ModFlags & Modifiers.ABSTRACT) == Modifiers.ABSTRACT && (ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) != 0) {
-                               Report.Error (418, Location, "'{0}': an abstract class cannot be sealed or static", GetSignatureForError ());
+                               Report.Error (418, Location, "`{0}': an abstract class cannot be sealed or static", GetSignatureForError ());
                                return null;
                        }
 
                        int accmods = Parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
                        ModFlags = Modifiers.Check (AllowedModifiersProp, ModFlags, accmods, Location);
 
-                       try {
-                               return base.DefineType ();
-                       }
-                       catch (CircularDepException e) {
-                               Report.SymbolRelatedToPreviousError (e.Container);
-                               Report.Error (146, Location, "Circular base class dependency involving '{0}' and '{1}'",
-                                       GetSignatureForError (), e.Container.GetSignatureForError ());
-                               WasTransitError = true;
-                               return null;
-                       }
+                       return base.DefineType ();
                }
 
                /// Search for at least one defined condition in ConditionalAttribute of attribute class
@@ -2883,7 +3007,7 @@ namespace Mono.CSharp {
                // FIXME: How do we deal with the user specifying a different
                // layout?
                //
-               public override TypeAttributes TypeAttr {
+               protected override TypeAttributes TypeAttr {
                        get {
                                return base.TypeAttr | DefaultTypeAttributes;
                        }
@@ -2903,8 +3027,8 @@ namespace Mono.CSharp {
                        Modifiers.PRIVATE;
 
                public Struct (NamespaceEntry ns, TypeContainer parent, MemberName name,
-                              int mod, Attributes attrs, Location l)
-                       : base (ns, parent, name, attrs, Kind.Struct, l)
+                              int mod, Attributes attrs)
+                       : base (ns, parent, name, attrs, Kind.Struct)
                {
                        int accmods;
                        
@@ -2913,7 +3037,7 @@ namespace Mono.CSharp {
                        else
                                accmods = Modifiers.PRIVATE;
                        
-                       this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
+                       this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, Location);
 
                        this.ModFlags |= Modifiers.SEALED;
                }
@@ -2928,29 +3052,11 @@ namespace Mono.CSharp {
                // in some cases (Sealed for example is mandatory for a class,
                // but what SequentialLayout can be changed
                //
-               public override TypeAttributes TypeAttr {
+               protected override TypeAttributes TypeAttr {
                        get {
                                return base.TypeAttr | DefaultTypeAttributes;
                        }
                }
-
-               public override TypeBuilder DefineType()
-               {
-                       if (InTransit) {
-                               InTransit = false;
-                               throw new CircularDepException (this);
-                       }
-
-                       try {
-                               return base.DefineType ();
-                       }
-                       catch (CircularDepException e) {
-                               InTransit = false;
-                               Report.SymbolRelatedToPreviousError (this);
-                               Error_TypeInListIsNotInterface (e.Container.Location, GetSignatureForError ());
-                               return null;
-                       }
-               }
        }
 
        /// <summary>
@@ -2958,8 +3064,6 @@ namespace Mono.CSharp {
        /// </summary>
        public class Interface : TypeContainer, IMemberContainer {
 
-               bool WasTransitError;
-
                /// <summary>
                ///   Modifiers allowed in a class declaration
                /// </summary>
@@ -2972,8 +3076,8 @@ namespace Mono.CSharp {
                        Modifiers.PRIVATE;
 
                public Interface (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
-                                 Attributes attrs, Location l)
-                       : base (ns, parent, name, attrs, Kind.Interface, l)
+                                 Attributes attrs)
+                       : base (ns, parent, name, attrs, Kind.Interface)
                {
                        int accmods;
 
@@ -2982,7 +3086,7 @@ namespace Mono.CSharp {
                        else
                                accmods = Modifiers.PRIVATE;
 
-                       this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
+                       this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, name.Location);
                }
 
                public override PendingImplementation GetPendingImplementations ()
@@ -2995,46 +3099,38 @@ namespace Mono.CSharp {
                        TypeAttributes.Abstract |
                        TypeAttributes.Interface;
 
-               public override TypeAttributes TypeAttr {
+               protected override TypeAttributes TypeAttr {
                        get {
                                return base.TypeAttr | DefaultTypeAttributes;
                        }
                }
 
-               public override TypeBuilder DefineType()
+               protected override bool VerifyClsCompliance (DeclSpace ds)
                {
-                       if (InTransit) {
-                               if (WasTransitError) 
-                                       return null;
-                               throw new CircularDepException (this);
-                       }
+                       if (!base.VerifyClsCompliance (ds))
+                               return false;
 
-                       try {
-                               return base.DefineType ();
-                       }
-                       catch (CircularDepException e) {
-                               Report.SymbolRelatedToPreviousError (e.Container);
-                               Report.Error (529, Location, "Inherited interface '{0}' causes a cycle in the interface hierarchy of '{1}'",
-                                       e.Container.GetSignatureForError (), GetSignatureForError ());
-                               WasTransitError = true;
-                               return null;
+                       if (ifaces != null) {
+                               foreach (Type t in ifaces) {
+                                       if (AttributeTester.IsClsCompliant (t))
+                                               continue;
+
+                                       Report.SymbolRelatedToPreviousError (t);
+                                       Report.Warning (3027, 1, Location, "`{0}' is not CLS-compliant because base interface `{1}' is not CLS-compliant",
+                                               GetSignatureForError (), TypeManager.CSharpName (t));
+                               }
                        }
-               }
 
+                       return true;
+               }
        }
 
        public abstract class MethodCore : MemberBase {
                public readonly Parameters Parameters;
                protected ToplevelBlock block;
                
-               //
-               // Parameters, cached for semantic analysis.
-               //
-               protected InternalParameters parameter_info;
-               protected Type [] parameter_types;
-
                // Whether this is an operator method.
-               public bool IsOperator;
+               public Operator IsOperator;
 
                //
                // The method we're overriding if this is an override method.
@@ -3045,9 +3141,9 @@ namespace Mono.CSharp {
 
                public MethodCore (TypeContainer parent, Expression type, int mod,
                                   int allowed_mod, bool is_interface, MemberName name,
-                                  Attributes attrs, Parameters parameters, Location loc)
+                                  Attributes attrs, Parameters parameters)
                        : base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name,
-                               attrs, loc)
+                               attrs)
                {
                        Parameters = parameters;
                        IsInterface = is_interface;
@@ -3058,14 +3154,14 @@ namespace Mono.CSharp {
                //
                public Type [] ParameterTypes {
                        get {
-                               return parameter_types;
+                               return Parameters.Types;
                        }
                }
 
-               public InternalParameters ParameterInfo
+               public Parameters ParameterInfo
                {
                        get {
-                               return parameter_info;
+                               return Parameters;
                        }
                }
                
@@ -3079,6 +3175,11 @@ namespace Mono.CSharp {
                        }
                }
 
+               public void SetYields ()
+               {
+                       ModFlags |= Modifiers.METHOD_YIELDS;
+               }
+
                protected override bool CheckBase ()
                {
                        if (!base.CheckBase ())
@@ -3097,7 +3198,7 @@ namespace Mono.CSharp {
                        // Is null for System.Object while compiling corlib and base interfaces
                        if (Parent.BaseCache == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
-                                       Report.Warning (109, Location, "The member '{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError (Parent));
+                                       Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
                                }
                                return true;
                        }
@@ -3115,34 +3216,33 @@ namespace Mono.CSharp {
                                        if (MemberType != TypeManager.TypeToCoreType (base_ret_type)) {
                                                Report.SymbolRelatedToPreviousError (base_method);
                                                if (this is PropertyBase) {
-                                                       Report.Error (1715, Location, "'{0}': type must be '{1}' to match overridden member '{2}'", 
+                                                       Report.Error (1715, Location, "`{0}': type must be `{1}' to match overridden member `{2}'", 
                                                                GetSignatureForError (), TypeManager.CSharpName (base_ret_type), TypeManager.CSharpSignature (base_method));
                                                }
                                                else {
-                                                       Report.Error (508, Location, GetSignatureForError (Parent) + ": cannot " +
-                                                               "change return type when overriding inherited member");
+                                                       Report.Error (508, Location, "`{0}': return type must be `{1}' to match overridden member `{2}'",
+                                                               GetSignatureForError (), TypeManager.CSharpName (base_ret_type), TypeManager.CSharpSignature (base_method));
                                                }
                                                return false;
                                        }
                                } else {
                                        if (base_method.IsAbstract && !IsInterface) {
                                                Report.SymbolRelatedToPreviousError (base_method);
-                                               Report.Error (533, Location, "'{0}' hides inherited abstract member", GetSignatureForError (Parent));
+                                               Report.Error (533, Location, "`{0}' hides inherited abstract member `{1}'",
+                                                       GetSignatureForError (), TypeManager.CSharpSignature (base_method));
                                                return false;
                                        }
                                }
 
                                if (base_method.IsSpecialName && !(this is PropertyBase)) {
-                                       Report.Error (561, Location, "'{0}': cannot override '{1}' because it is a special compiler-generated method", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (base_method));
+                                       Report.Error (115, Location, "`{0}': no suitable method found to override", GetSignatureForError ());
                                        return false;
                                }
 
-                               if (RootContext.WarningLevel > 2) {
-                                       if (Name == "Equals" && parameter_types.Length == 1 && parameter_types [0] == TypeManager.object_type)
-                                               Parent.Methods.HasEquals = true;
-                                       else if (Name == "GetHashCode" && parameter_types.Length == 0)
-                                               Parent.Methods.HasGetHashCode = true;
-                               }
+                               if (Name == "Equals" && Parameters.Count == 1 && ParameterTypes [0] == TypeManager.object_type)
+                                       Parent.Mark_HasEquals ();
+                               else if (Name == "GetHashCode" && Parameters.Empty)
+                                       Parent.Mark_HasGetHashCode ();
 
                                if ((ModFlags & Modifiers.OVERRIDE) != 0) {
                                        ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (base_method);
@@ -3150,7 +3250,8 @@ namespace Mono.CSharp {
                                                EmitContext ec = new EmitContext (this.Parent, this.Parent, Location, null, null, ModFlags, false);
                                                if (OptAttributes == null || !OptAttributes.Contains (TypeManager.obsolete_attribute_type, ec)) {
                                                        Report.SymbolRelatedToPreviousError (base_method);
-                                                       Report.Warning (672, 1, Location, "Member '{0}' overrides obsolete member. Add the Obsolete attribute to '{0}'", GetSignatureForError (Parent));
+                                                       Report.Warning (672, 1, Location, "Member `{0}' overrides obsolete member `{1}'. Add the Obsolete attribute to `{0}'",
+                                                               GetSignatureForError (), TypeManager.CSharpSignature (base_method) );
                                                }
                                        }
                                }
@@ -3162,17 +3263,17 @@ namespace Mono.CSharp {
                                if (conflict_symbol != null) {
                                        Report.SymbolRelatedToPreviousError (conflict_symbol);
                                        if (this is PropertyBase)
-                                               Report.Error (544, Location, "'{0}': cannot override because '{1}' is not a property", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (conflict_symbol));
+                                               Report.Error (544, Location, "`{0}': cannot override because `{1}' is not a property", GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
                                        else
-                                               Report.Error (505, Location, "'{0}': cannot override because '{1}' is not a method", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (conflict_symbol));
+                                               Report.Error (505, Location, "`{0}': cannot override because `{1}' is not a method", GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
                                } else
-                                       Report.Error (115, Location, "'{0}': no suitable methods found to override", GetSignatureForError (Parent));
+                                       Report.Error (115, Location, "`{0}': no suitable method found to override", GetSignatureForError ());
                                return false;
                        }
 
                        if (conflict_symbol == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
-                                       Report.Warning (109, Location, "The member '{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError (Parent));
+                                       Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
                                }
                                return true;
                        }
@@ -3182,13 +3283,13 @@ namespace Mono.CSharp {
                                        return true;
 
                                Report.SymbolRelatedToPreviousError (conflict_symbol);
-                               Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError (Parent));
+                               Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                                       GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
                        }
 
                        return true;
                }
 
-
                //
                // Performs various checks on the MethodInfo `mb' regarding the modifier flags
                // that have been defined.
@@ -3200,16 +3301,11 @@ namespace Mono.CSharp {
                {
                        bool ok = true;
 
-                       // TODO: replace with GetSignatureForError 
-                       string name = base_method.DeclaringType.Name + "." + base_method.Name;
-
                        if ((ModFlags & Modifiers.OVERRIDE) != 0){
                                if (!(base_method.IsAbstract || base_method.IsVirtual)){
-                                       Report.Error (
-                                               506, Location, Parent.MakeName (Name) +
-                                               ": cannot override inherited member `" +
-                                               name + "' because it is not " +
-                                               "virtual, abstract or override");
+                                       Report.Error (506, Location,
+                                               "`{0}': cannot override inherited member `{1}' because it is not marked virtual, abstract or override",
+                                                GetSignatureForError (), TypeManager.CSharpSignature (base_method));
                                        ok = false;
                                }
                                
@@ -3217,7 +3313,7 @@ namespace Mono.CSharp {
                                
                                if (base_method.IsFinal) {
                                        Report.SymbolRelatedToPreviousError (base_method);
-                                       Report.Error (239, Location, "'{0}': cannot override inherited member '{1}' because it is sealed",
+                                       Report.Error (239, Location, "`{0}': cannot override inherited member `{1}' because it is sealed",
                                                              GetSignatureForError (), TypeManager.CSharpSignature (base_method));
                                        ok = false;
                                }
@@ -3228,7 +3324,7 @@ namespace Mono.CSharp {
                                MethodAttributes base_classp = base_method.Attributes & MethodAttributes.MemberAccessMask;
 
                                if (!CheckAccessModifiers (thisp, base_classp, base_method)) {
-                                       Error_CannotChangeAccessModifiers (Parent, base_method, name);
+                                       Error_CannotChangeAccessModifiers (base_method, base_classp, null);
                                        ok = false;
                                }
                        }
@@ -3237,10 +3333,12 @@ namespace Mono.CSharp {
                                ModFlags |= Modifiers.NEW;
                                Report.SymbolRelatedToPreviousError (base_method);
                                if (!IsInterface && (base_method.IsVirtual || base_method.IsAbstract)) {
-                                       if (RootContext.WarningLevel >= 2)
-                                               Report.Warning (114, Location, "'{0}' hides inherited member '{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError (Parent), TypeManager.CSharpSignature (base_method));
-                               } else
-                                       Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError (Parent));
+                                       Report.Warning (114, 2, Location, "`{0}' hides inherited member `{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword",
+                                               GetSignatureForError (), TypeManager.CSharpSignature (base_method));
+                               } else {
+                                       Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                                               GetSignatureForError (), TypeManager.CSharpSignature (base_method));
+                               }
                        }
 
                        return ok;
@@ -3291,21 +3389,52 @@ namespace Mono.CSharp {
                                return (thisp == base_classp);
                        }
                }
-               
-               void Error_CannotChangeAccessModifiers (TypeContainer parent, MethodInfo base_method, string name)
+
+               public bool CheckAbstractAndExtern (bool has_block)
                {
-                       //
-                       // FIXME: report the old/new permissions?
-                       //
-                       Report.Error (
-                               507, Location, parent.MakeName (Name) +
-                               ": can't change the access modifiers when overriding inherited " +
-                               "member `" + name + "'");
+                       if (Parent.Kind == Kind.Interface)
+                               return true;
+
+                       if (has_block) {
+                               if ((ModFlags & Modifiers.EXTERN) != 0) {
+                                       Report.Error (179, Location, "`{0}' cannot declare a body because it is marked extern",
+                                               GetSignatureForError ());
+                                       return false;
+                               }
+
+                               if ((ModFlags & Modifiers.ABSTRACT) != 0) {
+                                       Report.Error (500, Location, "`{0}' cannot declare a body because it is marked abstract",
+                                               GetSignatureForError ());
+                                       return false;
+                               }
+                       } else {
+                               if ((ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0) {
+                                       Report.Error (501, Location, "`{0}' must declare a body because it is not marked abstract or extern",
+                                               GetSignatureForError ());
+                                       return false;
+                               }
+                       }
+
+                       return true;
+               }
+
+               protected void Error_CannotChangeAccessModifiers (MemberInfo base_method, MethodAttributes ma, string suffix)
+               {
+                       Report.SymbolRelatedToPreviousError (base_method);
+                       string base_name = TypeManager.GetFullNameSignature (base_method);
+                       string this_name = GetSignatureForError ();
+                       if (suffix != null) {
+                               base_name += suffix;
+                               this_name += suffix;
+                       }
+
+                       Report.Error (507, Location, "`{0}': cannot change access modifiers when overriding `{1}' inherited member `{2}'",
+                               this_name, Modifiers.GetDescription (ma), base_name);
                }
 
                protected static string Error722 {
                        get {
-                               return "'{0}': static types cannot be used as return types";
+                               return "`{0}': static types cannot be used as return types";
                        }
                }
 
@@ -3319,7 +3448,7 @@ namespace Mono.CSharp {
                /// </summary>
                protected abstract MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type);
 
-               protected virtual bool DoDefineParameters ()
+               protected bool DoDefineParameters ()
                {
                        EmitContext ec = Parent.EmitContext;
                        if (ec == null)
@@ -3327,25 +3456,63 @@ namespace Mono.CSharp {
 
                        bool old_unsafe = ec.InUnsafe;
                        ec.InUnsafe = InUnsafe;
+
+                       bool old_obsolete = ec.TestObsoleteMethodUsage;
+                       if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
+                               ec.TestObsoleteMethodUsage = false;
+
                        // Check if arguments were correct
-                       parameter_types = Parameters.GetParameterInfo (ec);
+                       if (!Parameters.Resolve (ec))
+                               return false;
+
                        ec.InUnsafe = old_unsafe;
+                       ec.TestObsoleteMethodUsage = old_obsolete;
 
-                       if ((parameter_types == null) ||
-                           !CheckParameters (Parent, parameter_types))
-                               return false;
+                       return CheckParameters (ParameterTypes);
+               }
 
-                       parameter_info = new InternalParameters (parameter_types, Parameters);
+               bool CheckParameters (Type [] parameters)
+               {
+                       bool error = false;
+                       DeclSpace ds = Parent;
 
-                       Parameter array_param = Parameters.ArrayParameter;
-                       if ((array_param != null) &&
-                           (!array_param.ParameterType.IsArray ||
-                            (array_param.ParameterType.GetArrayRank () != 1))) {
-                               Report.Error (225, Location, "params parameter has to be a single dimensional array");
-                               return false;
+                       foreach (Type partype in parameters){
+                               if (partype == TypeManager.void_type) {
+                                       Report.Error (
+                                               1547, Location, "Keyword 'void' cannot " +
+                                               "be used in this context");
+                                       return false;
+                               }
+
+                               if (partype.IsPointer){
+                                       if (!UnsafeOK (ds))
+                                               error = true;
+                                       if (!TypeManager.VerifyUnManaged (TypeManager.GetElementType (partype), Location))
+                                               error = true;
+                               }
+
+                               if (ds.AsAccessible (partype, ModFlags))
+                                       continue;
+
+                               if (this is Indexer)
+                                       Report.Error (55, Location,
+                                               "Inconsistent accessibility: parameter type `" +
+                                               TypeManager.CSharpName (partype) + "' is less " +
+                                               "accessible than indexer `" + GetSignatureForError () + "'");
+                               else if ((this is Method) && ((Method) this).IsOperator != null)
+                                       Report.Error (57, Location,
+                                               "Inconsistent accessibility: parameter type `" +
+                                               TypeManager.CSharpName (partype) + "' is less " +
+                                               "accessible than operator `" + GetSignatureForError () + "'");
+                               else
+                                       Report.Error (51, Location,
+                                               "Inconsistent accessibility: parameter type `" +
+                                               TypeManager.CSharpName (partype) + "' is less " +
+                                               "accessible than method `" + GetSignatureForError () + "'");
+                               error = true;
                        }
 
-                       return true;
+                       return !error;
                }
 
                public override string[] ValidAttributeTargets {
@@ -3357,8 +3524,8 @@ namespace Mono.CSharp {
                protected override bool VerifyClsCompliance (DeclSpace ds)
                {
                        if (!base.VerifyClsCompliance (ds)) {
-                               if ((ModFlags & Modifiers.ABSTRACT) != 0 && IsExposedFromAssembly (ds) && ds.IsClsCompliaceRequired (ds)) {
-                                       Report.Error (3011, Location, "'{0}': only CLS-compliant members can be abstract", GetSignatureForError ());
+                               if ((ModFlags & Modifiers.ABSTRACT) != 0 && IsExposedFromAssembly (ds) && ds.IsClsComplianceRequired (ds)) {
+                                       Report.Error (3011, Location, "`{0}': only CLS-compliant members can be abstract", GetSignatureForError ());
                                }
                                return false;
                        }
@@ -3372,22 +3539,25 @@ namespace Mono.CSharp {
                                        Report.Error (3003, Location, "Type of `{0}' is not CLS-compliant",
                                                      GetSignatureForError ());
                                else
-                                       Report.Error (3002, Location, "Return type of '{0}' is not CLS-compliant",
+                                       Report.Error (3002, Location, "Return type of `{0}' is not CLS-compliant",
                                                      GetSignatureForError ());
                        }
 
-                       AttributeTester.AreParametersCompliant (Parameters.FixedParameters, Location);
+                       Parameters.VerifyClsCompliance ();
 
                        return true;
                }
 
                protected bool IsDuplicateImplementation (MethodCore method)
                {
-                       if ((method == this) || (method.Name != Name))
+                       if (method == this || !(method.MemberName.Equals (MemberName)))
                                return false;
 
                        Type[] param_types = method.ParameterTypes;
-                       if (param_types == null)
+                       // This never happen. Rewrite this as Equal
+                       if (param_types == null && ParameterTypes == null)
+                               return true;
+                       if (param_types == null || ParameterTypes == null)
                                return false;
 
                        if (param_types.Length != ParameterTypes.Length)
@@ -3406,31 +3576,27 @@ namespace Mono.CSharp {
                        //
                        // Try to report 663: method only differs on out/ref
                        //
-                       ParameterData info = ParameterInfo;
-                       ParameterData other_info = method.ParameterInfo;
+                       Parameters info = ParameterInfo;
+                       Parameters other_info = method.ParameterInfo;
                        for (int i = 0; i < info.Count; i++){
                                if (info.ParameterModifier (i) != other_info.ParameterModifier (i)){
-                                       Report.Error (663, Location, "Overload method only differs in parameter modifier");
+                                       Report.SymbolRelatedToPreviousError (method);
+                                       Report.Error (663, Location, "`{0}': Methods cannot differ only on their use of ref and out on a parameters",
+                                               GetSignatureForError ());
                                        return false;
                                }
                        }
 
                        Report.SymbolRelatedToPreviousError (method);
                        if (this is Operator && method is Operator)
-                               Report.Error (557, Location, "Duplicate user-defined conversion in type '{0}'", Parent.Name);
+                               Report.Error (557, Location, "Duplicate user-defined conversion in type `{0}'", Parent.Name);
                        else
-                               Report.Error (111, Location, TypeContainer.Error111, Parent.Name, Name);
+                               Report.Error (111, Location, TypeContainer.Error111, GetSignatureForError ());
                        return true;
                }
 
-               public override bool IsUsed
-               {
-                       get {
-                               if (IsExplicitImpl)
-                                       return true;
-
-                               return base.IsUsed;
-                       }
+               public override bool IsUsed {
+                       get { return IsExplicitImpl || base.IsUsed; }
                }
 
                //
@@ -3461,17 +3627,6 @@ namespace Mono.CSharp {
                        get { return "M:"; }
                }
 
-               protected override void VerifyObsoleteAttribute()
-               {
-                       base.VerifyObsoleteAttribute ();
-
-                       if (parameter_types == null)
-                               return;
-
-                       foreach (Type type in parameter_types) {
-                               CheckUsageOfObsoleteAttribute (type);
-                       }
-               }
        }
 
        public class SourceMethod : ISourceMethod
@@ -3486,7 +3641,7 @@ namespace Mono.CSharp {
                        this.builder = builder;
                        
                        CodeGen.SymbolWriter.OpenMethod (
-                               file, this, start.Row, 0, end.Row, 0);
+                               file, this, start.Row, start.Column, end.Row, start.Column);
                }
 
                public string Name {
@@ -3523,11 +3678,11 @@ namespace Mono.CSharp {
                                return null;
 
                        Location start_loc = block.StartLocation;
-                       if (Location.IsNull (start_loc))
+                       if (start_loc.IsNull)
                                return null;
 
                        Location end_loc = block.EndLocation;
-                       if (Location.IsNull (end_loc))
+                       if (end_loc.IsNull)
                                return null;
 
                        ISourceFile file = start_loc.SourceFile;
@@ -3570,11 +3725,10 @@ namespace Mono.CSharp {
                // return_type can be "null" for VOID values.
                //
                public Method (TypeContainer ds, Expression return_type, int mod, bool is_iface,
-                              MemberName name, Parameters parameters, Attributes attrs,
-                              Location l)
+                              MemberName name, Parameters parameters, Attributes attrs)
                        : base (ds, return_type, mod,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
-                               is_iface, name, attrs, parameters, l)
+                               is_iface, name, attrs, parameters)
                {
                }
 
@@ -3586,34 +3740,10 @@ namespace Mono.CSharp {
                
                public override string GetSignatureForError()
                {
-                       if (MethodBuilder == null) {
-                               return GetSignatureForError (Parent);
-                       }
-                       return TypeManager.CSharpSignature (MethodBuilder);
-               }
-
-               /// <summary>
-               /// Use this method when MethodBuilder is null
-               /// </summary>
-               public override string GetSignatureForError (TypeContainer tc)
-               {
-                       // TODO: get params from somewhere
-                       if (parameter_info == null)
-                               return base.GetSignatureForError (tc);
-
-                       // TODO: move to parameters
-                       System.Text.StringBuilder args = new System.Text.StringBuilder ();
-                       if (parameter_info.Parameters.FixedParameters != null) {
-                               for (int i = 0; i < parameter_info.Parameters.FixedParameters.Length; ++i) {
-                                       Parameter p = parameter_info.Parameters.FixedParameters [i];
-                                       args.Append (p.GetSignatureForError ());
-
-                                       if (i < parameter_info.Parameters.FixedParameters.Length - 1)
-                                               args.Append (',');
-                               }
-                       }
+                       if (IsOperator != null)
+                               return IsOperator.GetSignatureForError ();
 
-                       return String.Concat (base.GetSignatureForError (tc), "(", args.ToString (), ")");
+                       return base.GetSignatureForError () + Parameters.GetSignatureForError ();
                }
 
                 void DuplicateEntryPoint (MethodInfo b, Location location)
@@ -3621,11 +3751,11 @@ namespace Mono.CSharp {
                         Report.Error (
                                 17, location,
                                 "Program `" + CodeGen.FileName +
-                                "'  has more than one entry point defined: `" +
+                                "' has more than one entry point defined: `" +
                                 TypeManager.CSharpSignature(b) + "'");
                 }
 
-                public bool IsEntryPoint (MethodBuilder b, InternalParameters pinfo)
+                bool IsEntryPoint (MethodBuilder b, Parameters pinfo)
                 {
                         if (b.ReturnType != TypeManager.void_type &&
                             b.ReturnType != TypeManager.int32_type)
@@ -3679,18 +3809,19 @@ namespace Mono.CSharp {
                        }
 
                        if (a.Type == TypeManager.conditional_attribute_type) {
-                               if (IsOperator || IsExplicitImpl) {
-                                       Report.Error (577, Location, "Conditional not valid on '{0}' because it is a destructor, operator, or explicit interface implementation", GetSignatureForError ());
+                               if (IsOperator != null || IsExplicitImpl) {
+                                       Report.Error (577, Location, "Conditional not valid on `{0}' because it is a constructor, destructor, operator or explicit interface implementation",
+                                               GetSignatureForError ());
                                        return;
                                }
 
                                if (ReturnType != TypeManager.void_type) {
-                                       Report.Error (578, Location, "Conditional not valid on '{0}' because its return type is not void", GetSignatureForError ());
+                                       Report.Error (578, Location, "Conditional not valid on `{0}' because its return type is not void", GetSignatureForError ());
                                        return;
                                }
 
                                if ((ModFlags & Modifiers.OVERRIDE) != 0) {
-                                       Report.Error (243, Location, "Conditional not valid on '{0}' because it is an override method", GetSignatureForError ());
+                                       Report.Error (243, Location, "Conditional not valid on `{0}' because it is an override method", GetSignatureForError ());
                                        return;
                                }
 
@@ -3699,14 +3830,15 @@ namespace Mono.CSharp {
                                        return;
                                }
 
-                               if (MethodData.IsImplementing) {
-                                       Report.Error (629, Location, "Conditional member '{0}' cannot implement interface member", GetSignatureForError ());
+                               if (MethodData.implementing != null) {
+                                       Report.Error (629, Location, "Conditional member `{0}' cannot implement interface member `{1}'",
+                                               GetSignatureForError (), TypeManager.CSharpSignature (MethodData.implementing));
                                        return;
                                }
 
-                               for (int i = 0; i < parameter_info.Count; ++i) {
-                                       if ((parameter_info.ParameterModifier (i) & Parameter.Modifier.OUT) != 0) {
-                                               Report.Error (685, Location, "Conditional method '{0}' cannot have an out parameter", GetSignatureForError ());
+                               for (int i = 0; i < ParameterInfo.Count; ++i) {
+                                       if ((ParameterInfo.ParameterModifier (i) & Parameter.Modifier.OUTMASK) != 0) {
+                                               Report.Error (685, Location, "Conditional method `{0}' cannot have an out parameter", GetSignatureForError ());
                                                return;
                                        }
                                }
@@ -3766,6 +3898,9 @@ namespace Mono.CSharp {
                        if (!DoDefine ())
                                return false;
 
+                       if (!CheckAbstractAndExtern (block != null))
+                               return false;
+
                        if (RootContext.StdLib && (ReturnType == TypeManager.arg_iterator_type || ReturnType == TypeManager.typed_reference_type)) {
                                Error1599 (Location, ReturnType);
                                return false;
@@ -3774,26 +3909,29 @@ namespace Mono.CSharp {
                        if (!CheckBase ())
                                return false;
 
-                       if (IsOperator)
+                       if (IsOperator != null)
                                flags |= MethodAttributes.SpecialName | MethodAttributes.HideBySig;
 
-                       MethodData = new MethodData (this, ParameterInfo, ModFlags, flags, this);
+                       MethodData = new MethodData (this, ModFlags, flags, this);
 
                        if (!MethodData.Define (Parent))
                                return false;
 
+                       if (ReturnType == TypeManager.void_type && ParameterTypes.Length == 0 && 
+                               Name == "Finalize" && !(this is Destructor)) {
+                               Report.Warning (465, 1, Location, "Introducing a 'Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?");
+                       }
+
                        //
                        // Setup iterator if we are one
                        //
                        if ((ModFlags & Modifiers.METHOD_YIELDS) != 0){
-                               Iterator iterator = new Iterator (
-                                       Parent, Name, MemberType,
-                                       ParameterInfo, ModFlags, block, Location);
+                               Iterator iterator = new Iterator (this,
+                                       Parent,
+                                       ModFlags);
 
                                if (!iterator.DefineIterator ())
                                        return false;
-
-                               block = iterator.Block;
                        }
 
                        MethodBuilder = MethodData.MethodBuilder;
@@ -3818,7 +3956,7 @@ namespace Mono.CSharp {
                                         }
                                 } else {
                                        if (RootContext.WarningLevel >= 4)
-                                               Report.Warning (28, Location, "'{0}' has the wrong signature to be an entry point", TypeManager.CSharpSignature(MethodBuilder));
+                                               Report.Warning (28, 4, Location, "`{0}' has the wrong signature to be an entry point", TypeManager.CSharpSignature(MethodBuilder));
                                }
                        }
 
@@ -3850,7 +3988,7 @@ namespace Mono.CSharp {
 
                public static void Error1599 (Location loc, Type t)
                {
-                       Report.Error (1599, loc, "Method or delegate cannot return type '{0}'", TypeManager.CSharpName (t));
+                       Report.Error (1599, loc, "Method or delegate cannot return type `{0}'", TypeManager.CSharpName (t));
                }
 
                protected override MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type)
@@ -3876,7 +4014,7 @@ namespace Mono.CSharp {
                        if (!base.VerifyClsCompliance (ds))
                                return false;
 
-                       if (parameter_types.Length > 0) {
+                       if (ParameterInfo.Count > 0) {
                                ArrayList al = (ArrayList)ds.MemberCache.Members [Name];
                                if (al.Count > 1)
                                        ds.MemberCache.VerifyClsParameterConflict (al, this, MethodBuilder);
@@ -3885,17 +4023,11 @@ namespace Mono.CSharp {
                        return true;
                }
 
-
-               void IIteratorContainer.SetYields ()
-               {
-                       ModFlags |= Modifiers.METHOD_YIELDS;
-               }
-       
                #region IMethodData Members
 
                public CallingConventions CallingConventions {
                        get {
-                               CallingConventions cc = Parameters.GetCallingConvention ();
+                               CallingConventions cc = Parameters.CallingConvention;
                                if (Parameters.HasArglist)
                                        block.HasVarargs = true;
 
@@ -3943,13 +4075,14 @@ namespace Mono.CSharp {
 
                public EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig)
                {
-                       return new EmitContext (
+                       EmitContext ec = new EmitContext (
                                tc, Parent, Location, ig, ReturnType, ModFlags, false);
-               }
 
-               public ObsoleteAttribute GetObsoleteAttribute ()
-               {
-                       return GetObsoleteAttribute (Parent);
+                       ec.CurrentIterator = tc as Iterator;
+                       if (ec.CurrentIterator != null)
+                               ec.CurrentAnonymousMethod = ec.CurrentIterator.Host;
+
+                       return ec;
                }
 
                /// <summary>
@@ -4003,14 +4136,11 @@ namespace Mono.CSharp {
        public abstract class ConstructorInitializer {
                ArrayList argument_list;
                protected ConstructorInfo base_constructor;
-               Parameters parameters;
                Location loc;
                
-               public ConstructorInitializer (ArrayList argument_list, Parameters parameters,
-                                              Location loc)
+               public ConstructorInitializer (ArrayList argument_list, Location loc)
                {
                        this.argument_list = argument_list;
-                       this.parameters = parameters;
                        this.loc = loc;
                }
 
@@ -4020,13 +4150,13 @@ namespace Mono.CSharp {
                        }
                }
 
-               public bool Resolve (ConstructorBuilder caller_builder, EmitContext ec)
+               public bool Resolve (ConstructorBuilder caller_builder, Block block, EmitContext ec)
                {
                        Expression base_constructor_group;
                        Type t;
                        bool error = false;
 
-                       ec.CurrentBlock = new ToplevelBlock (Block.Flags.Implicit, parameters, loc);
+                       ec.CurrentBlock = block;
 
                        if (argument_list != null){
                                foreach (Argument a in argument_list){
@@ -4043,7 +4173,7 @@ namespace Mono.CSharp {
                                t = ec.ContainerType.BaseType;
                                if (ec.ContainerType.IsValueType) {
                                        Report.Error (522, loc,
-                                               "structs cannot call base class constructors");
+                                               "`{0}': Struct constructors cannot call base constructors", TypeManager.CSharpSignature (caller_builder));
                                        return false;
                                }
                        } else
@@ -4070,26 +4200,26 @@ namespace Mono.CSharp {
                        
                        if (base_constructor == null) {
                                if (errors == Report.Errors)
-                                       Report.Error (1501, loc, "Can not find a constructor for this argument list");
+                                       Invocation.Error_WrongNumArguments (loc, TypeManager.CSharpSignature (caller_builder),
+                                               argument_list.Count);
                                return false;
                        }
 
                        if (error) {
-                               Report.Error (122, loc, "`{0}' is inaccessible due to its protection level",
-                                             TypeManager.CSharpSignature (base_constructor));
+                               Expression.ErrorIsInaccesible (loc, TypeManager.CSharpSignature (base_constructor));
                                base_constructor = null;
                                return false;
                        }
 
                        if (base_constructor == caller_builder){
-                               Report.Error (516, loc, "Constructor `{0}' can not call itself", TypeManager.CSharpSignature (caller_builder));
+                               Report.Error (516, loc, "Constructor `{0}' cannot call itself", TypeManager.CSharpSignature (caller_builder));
                                return false;
                        }
                        
                        return true;
                }
 
-               public void Emit (EmitContext ec)
+               public virtual void Emit (EmitContext ec)
                {
                        if (base_constructor != null){
                                ec.Mark (loc, false);
@@ -4099,96 +4229,33 @@ namespace Mono.CSharp {
                                        Invocation.EmitCall (ec, true, false, ec.GetThis (loc), base_constructor, argument_list, loc);
                        }
                }
+       }
 
-               /// <summary>
-               /// Method search for base ctor. (We do not cache it).
-               /// </summary>
-               Constructor GetOverloadedConstructor (TypeContainer tc)
-               {
-                       if (tc.InstanceConstructors == null)
-                               return null;
-
-                       foreach (Constructor c in tc.InstanceConstructors) {
-                               if (Arguments == null) {
-                                       if (c.ParameterTypes.Length == 0)
-                                               return c;
-
-                                       continue;
-                               }
-
-                               bool ok = true;
-
-                               int count = c.ParameterInfo.Count;
-                               if ((count > 0) &&
-                                   c.ParameterInfo.ParameterModifier (count - 1) == Parameter.Modifier.PARAMS) {
-                                       for (int i = 0; i < count-1; i++)
-                                               if (c.ParameterTypes [i] != ((Argument)Arguments [i]).Type) {
-                                                       ok = false;
-                                                       break;
-                                               }
-                               } else {
-                                       if (c.ParameterTypes.Length != Arguments.Count)
-                                               continue;
-
-                                       for (int i = 0; i < Arguments.Count; ++i)
-                                               if (c.ParameterTypes [i] != ((Argument)Arguments [i]).Type) {
-                                                       ok = false;
-                                                       break;
-                                               }
-                               }
-
-                               if (!ok)
-                                       continue;
-
-                               return c;
-                       }
-
-                       return null;
-               }
-
-               //TODO: implement caching when it will be necessary
-               public virtual void CheckObsoleteAttribute (TypeContainer tc, Location loc)
+       public class ConstructorBaseInitializer : ConstructorInitializer {
+               public ConstructorBaseInitializer (ArrayList argument_list, Location l) :
+                       base (argument_list, l)
                {
-                       Constructor ctor = GetOverloadedConstructor (tc);
-                       if (ctor == null)
-                               return;
-
-                       ObsoleteAttribute oa = ctor.GetObsoleteAttribute (tc);
-                       if (oa == null)
-                               return;
-
-                       AttributeTester.Report_ObsoleteMessage (oa, ctor.GetSignatureForError (), loc);
                }
        }
 
-       public class ConstructorBaseInitializer : ConstructorInitializer {
-               public ConstructorBaseInitializer (ArrayList argument_list, Parameters pars, Location l) :
-                       base (argument_list, pars, l)
+       class GeneratedBaseInitializer: ConstructorBaseInitializer {
+               public GeneratedBaseInitializer (Location loc):
+                       base (null, loc)
                {
                }
 
-               public override void CheckObsoleteAttribute(TypeContainer tc, Location loc) {
-                       if (base_constructor == null)
-                               return;
-
-                       TypeContainer type_ds = TypeManager.LookupTypeContainer (tc.TypeBuilder.BaseType);
-                       if (type_ds == null) {
-                               ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (base_constructor);
-
-                               if (oa != null)
-                                       AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (base_constructor), loc);
-
-                               return;
-                       }
-
-                       base.CheckObsoleteAttribute (type_ds, loc);
+               public override void Emit(EmitContext ec)
+               {
+                       bool old = ec.TestObsoleteMethodUsage;
+                       ec.TestObsoleteMethodUsage = false;
+                       base.Emit (ec);
+                       ec.TestObsoleteMethodUsage = old;
                }
-
        }
 
        public class ConstructorThisInitializer : ConstructorInitializer {
-               public ConstructorThisInitializer (ArrayList argument_list, Parameters pars, Location l) :
-                       base (argument_list, pars, l)
+               public ConstructorThisInitializer (ArrayList argument_list, Location l) :
+                       base (argument_list, l)
                {
                }
        }
@@ -4216,21 +4283,13 @@ namespace Mono.CSharp {
                // my very own code has static constructors.
                //
                public Constructor (TypeContainer ds, string name, int mod, Parameters args,
-                                   ConstructorInitializer init, Location l)
-                       : base (ds, null, mod, AllowedModifiers, false, new MemberName (name),
-                               null, args, l)
+                                   ConstructorInitializer init, Location loc)
+                       : base (ds, null, mod, AllowedModifiers, false, new MemberName (name, loc),
+                               null, args)
                {
                        Initializer = init;
                }
 
-               public override string GetSignatureForError()
-               {
-                       if (ConstructorBuilder == null)
-                               return GetSignatureForError (Parent);
-
-                       return TypeManager.CSharpSignature (ConstructorBuilder);
-               }
-
                public bool HasCompliantArgs {
                        get {
                                return has_compliant_args;
@@ -4250,12 +4309,9 @@ namespace Mono.CSharp {
                public bool IsDefault ()
                {
                        if ((ModFlags & Modifiers.STATIC) != 0)
-                               return  (Parameters.FixedParameters == null ? true : Parameters.Empty) &&
-                                       (Parameters.ArrayParameter == null ? true : Parameters.Empty);
+                               return Parameters.Empty;
                        
-                       else
-                               return  (Parameters.FixedParameters == null ? true : Parameters.Empty) &&
-                                       (Parameters.ArrayParameter == null ? true : Parameters.Empty) &&
+                       return Parameters.Empty &&
                                        (Initializer is ConstructorBaseInitializer) &&
                                        (Initializer.Arguments == null);
                }
@@ -4304,19 +4360,18 @@ namespace Mono.CSharp {
                        if (Parent.Kind == Kind.Struct) {
                                if (ParameterTypes.Length == 0) {
                                        Report.Error (568, Location, 
-                                               "Structs can not contain explicit parameterless " +
-                                               "constructors");
+                                               "Structs cannot contain explicit parameterless constructors");
                                        return false;
                                }
 
                                if ((ModFlags & Modifiers.PROTECTED) != 0) {
-                                       Report.Error (666, Location, "Protected member in struct declaration");
+                                       Report.Error (666, Location, "`{0}': new protected member declared in struct", GetSignatureForError ());
                                        return false;
                                }
                        }
 
                        if ((RootContext.WarningLevel >= 4) && ((Parent.ModFlags & Modifiers.SEALED) != 0 && (ModFlags & Modifiers.PROTECTED) != 0)) {
-                               Report.Warning (628, Location, "'{0}': new protected member declared in sealed class", GetSignatureForError (Parent));
+                               Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
                        }
                        
                        return true;
@@ -4327,6 +4382,9 @@ namespace Mono.CSharp {
                //
                public override bool Define ()
                {
+                       if (ConstructorBuilder != null)
+                               return true;
+
                        MethodAttributes ca = (MethodAttributes.RTSpecialName |
                                               MethodAttributes.SpecialName);
                        
@@ -4349,6 +4407,9 @@ namespace Mono.CSharp {
                                else
                                        ca |= MethodAttributes.Private;
                        }
+
+                       if (!CheckAbstractAndExtern (block != null))
+                               return false;
                        
                        // Check if arguments were correct.
                        if (!CheckBase ())
@@ -4360,14 +4421,18 @@ namespace Mono.CSharp {
 
                        if ((ModFlags & Modifiers.UNSAFE) != 0)
                                ConstructorBuilder.InitLocals = false;
+
+                       if (Parent.IsComImport) {
+                               if (!IsDefault ()) {
+                                       Report.Error (669, Location, "`{0}': A class with the ComImport attribute cannot have a user-defined constructor",
+                                               Parent.GetSignatureForError ());
+                                       return false;
+                               }
+                               ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.InternalCall);
+                       }
                        
                        TypeManager.AddMethod (ConstructorBuilder, this);
 
-                       //
-                       // HACK because System.Reflection.Emit is lame
-                       //
-                       TypeManager.RegisterMethod (ConstructorBuilder, ParameterInfo, ParameterTypes);
-
                        return true;
                }
 
@@ -4377,30 +4442,23 @@ namespace Mono.CSharp {
                public override void Emit ()
                {
                        EmitContext ec = CreateEmitContext (null, null);
+                       if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
+                               ec.TestObsoleteMethodUsage = false;
 
-                       //
-                       // extern methods have no bodies
-                       //
-                       if ((ModFlags & Modifiers.EXTERN) != 0) {
-                               if ((block != null) && ((ModFlags & Modifiers.EXTERN) != 0)) {
-                                       Report.Error (
-                                               179, Location, "External constructor `" +
-                                               TypeManager.CSharpSignature (ConstructorBuilder) +
-                                               "' can not have a body");
-                                       return;
-                               }
-                       } else if (block == null) {
-                               Report.Error (
-                                       501, Location, "Constructor `" +
-                                       TypeManager.CSharpSignature (ConstructorBuilder) +
-                                       "' must declare a body since it is not marked extern");
-                               return;
+                       // If this is a non-static `struct' constructor and doesn't have any
+                       // initializer, it must initialize all of the struct's fields.
+                       if ((Parent.Kind == Kind.Struct) &&
+                           ((ModFlags & Modifiers.STATIC) == 0) && (Initializer == null))
+                               Block.AddThisVariable (Parent, Location);
+
+                       if (block != null) {
+                               if (!block.ResolveMeta (ec, ParameterInfo))
+                                       block = null;
                        }
 
                        if ((ModFlags & Modifiers.STATIC) == 0){
                                if (Parent.Kind == Kind.Class && Initializer == null)
-                                       Initializer = new ConstructorBaseInitializer (
-                                               null, Parameters.EmptyReadOnlyParameters, Location);
+                                       Initializer = new GeneratedBaseInitializer (Location);
 
 
                                //
@@ -4408,12 +4466,13 @@ namespace Mono.CSharp {
                                // `this' access
                                //
                                ec.IsStatic = true;
-                               if (Initializer != null && !Initializer.Resolve (ConstructorBuilder, ec))
+                               if ((Initializer != null) &&
+                                   !Initializer.Resolve (ConstructorBuilder, block, ec))
                                        return;
                                ec.IsStatic = false;
                        }
 
-                       Parameters.LabelParameters (ec, ConstructorBuilder, Location);
+                       Parameters.ApplyAttributes (ec, ConstructorBuilder);
                        
                        SourceMethod source = SourceMethod.Create (
                                Parent, ConstructorBuilder, block);
@@ -4433,10 +4492,6 @@ namespace Mono.CSharp {
                                }
                        }
                        if (Initializer != null) {
-                               if (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent) == null)
-                                       Initializer.CheckObsoleteAttribute (Parent, Location);
-                               else
-                                       ec.TestObsoleteMethodUsage = false;
                                Initializer.Emit (ec);
                        }
                        
@@ -4446,13 +4501,7 @@ namespace Mono.CSharp {
                        if (OptAttributes != null) 
                                OptAttributes.Emit (ec, this);
 
-                       // If this is a non-static `struct' constructor and doesn't have any
-                       // initializer, it must initialize all of the struct's fields.
-                       if ((Parent.Kind == Kind.Struct) &&
-                           ((ModFlags & Modifiers.STATIC) == 0) && (Initializer == null))
-                               Block.AddThisVariable (Parent, Location);
-
-                       ec.EmitTopBlock (block, ParameterInfo, Location);
+                       ec.EmitTopBlock (this, block);
 
                        if (source != null)
                                source.CloseMethod ();
@@ -4474,19 +4523,24 @@ namespace Mono.CSharp {
                        return null;
                }
 
+               public override string GetSignatureForError()
+               {
+                       return base.GetSignatureForError () + Parameters.GetSignatureForError ();
+               }
+
                protected override bool VerifyClsCompliance (DeclSpace ds)
                {
                        if (!base.VerifyClsCompliance (ds) || !IsExposedFromAssembly (ds)) {
                                return false;
                        }
                        
-                       if (parameter_types.Length > 0) {
+                       if (ParameterInfo.Count > 0) {
                                ArrayList al = (ArrayList)ds.MemberCache.Members [".ctor"];
                                if (al.Count > 3)
                                        ds.MemberCache.VerifyClsParameterConflict (al, this, ConstructorBuilder);
  
                                if (ds.TypeBuilder.IsSubclassOf (TypeManager.attribute_type)) {
-                                       foreach (Type param in parameter_types) {
+                                       foreach (Type param in ParameterTypes) {
                                                if (param.IsArray) {
                                                        return true;
                                                }
@@ -4501,7 +4555,7 @@ namespace Mono.CSharp {
 
                public System.Reflection.CallingConventions CallingConventions {
                        get {
-                               CallingConventions cc = Parameters.GetCallingConvention ();
+                               CallingConventions cc = Parameters.CallingConvention;
 
                                if (Parent.Kind == Kind.Class)
                                        if ((ModFlags & Modifiers.STATIC) == 0)
@@ -4537,11 +4591,6 @@ namespace Mono.CSharp {
                        return new EmitContext (Parent, Location, ig_, null, ModFlags, true);
                }
 
-               public ObsoleteAttribute GetObsoleteAttribute ()
-               {
-                       return null;
-               }
-
                public bool IsExcluded(EmitContext ec)
                {
                        return false;
@@ -4558,17 +4607,17 @@ namespace Mono.CSharp {
                CallingConventions CallingConventions { get; }
                Location Location { get; }
                MemberName MethodName { get; }
-               Type[] ParameterTypes { get; }
                Type ReturnType { get; }
+               Parameters ParameterInfo { get; }
 
                Attributes OptAttributes { get; }
-               ToplevelBlock Block { get; }
+               ToplevelBlock Block { get; set; }
 
                EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig);
                ObsoleteAttribute GetObsoleteAttribute ();
-               string GetSignatureForError (TypeContainer tc);
+               string GetSignatureForError ();
                bool IsExcluded (EmitContext ec);
-               bool IsClsCompliaceRequired (DeclSpace ds);
+               bool IsClsComplianceRequired (DeclSpace ds);
                void SetMemberIsUsed ();
        }
 
@@ -4579,15 +4628,10 @@ namespace Mono.CSharp {
 
                readonly IMethodData method;
 
-               //
-               // The return type of this method
-               //
-               public readonly InternalParameters ParameterInfo;
-
                //
                // Are we implementing an interface ?
                //
-               public bool IsImplementing = false;
+               public MethodInfo implementing;
 
                //
                // Protected data.
@@ -4603,11 +4647,10 @@ namespace Mono.CSharp {
                        }
                }
 
-               public MethodData (MemberBase member, InternalParameters parameters,
+               public MethodData (MemberBase member,
                                   int modifiers, MethodAttributes flags, IMethodData method)
                {
                        this.member = member;
-                       this.ParameterInfo = parameters;
                        this.modifiers = modifiers;
                        this.flags = flags;
 
@@ -4616,46 +4659,56 @@ namespace Mono.CSharp {
 
                public bool Define (TypeContainer container)
                {
-                       MethodInfo implementing = null;
-
                        string name = method.MethodName.Name;
                        string method_name = name;
 
-                       Type[] ParameterTypes = method.ParameterTypes;
-
                        if (container.Pending != null){
                                if (member is Indexer) // TODO: test it, but it should work without this IF
                                        implementing = container.Pending.IsInterfaceIndexer (
-                                               member.InterfaceType, method.ReturnType, ParameterInfo);
+                                               member.InterfaceType, method.ReturnType, method.ParameterInfo);
                                else
                                        implementing = container.Pending.IsInterfaceMethod (
-                                               member.InterfaceType, name, method.ReturnType, ParameterInfo);
+                                               member.InterfaceType, name, method.ReturnType, method.ParameterInfo);
 
                                if (member.InterfaceType != null){
                                        if (implementing == null){
                                                if (member is PropertyBase) {
-                                                       Report.Error (550, method.Location, "'{0}' is an accessor not found in interface member '{1}'",
-                                                               method.GetSignatureForError (container), member.Name);
+                                                       Report.Error (550, method.Location, "`{0}' is an accessor not found in interface member `{1}{2}'",
+                                                               method.GetSignatureForError (), TypeManager.CSharpName (member.InterfaceType),
+                                                               member.GetSignatureForError ().Substring (member.GetSignatureForError ().LastIndexOf ('.')));
 
                                                } else {
                                                        Report.Error (539, method.Location,
-                                                               "'{0}' in explicit interface declaration is not a member of interface", member.GetSignatureForError () );
+                                                               "`{0}.{1}' in explicit interface declaration is not a member of interface",
+                                                               TypeManager.CSharpName (member.InterfaceType), member.ShortName);
                                                }
                                                return false;
                                        }
-                                       if (implementing.IsSpecialName && !((member is PropertyBase || member is EventProperty))) {
+                                       if (implementing.IsSpecialName && !(method is AbstractPropertyEventMethod)) {
                                                Report.SymbolRelatedToPreviousError (implementing);
-                                               Report.Error (683, method.Location, "'{0}' explicit method implementation cannot implement '{1}' because it is an accessor",
+                                               Report.Error (683, method.Location, "`{0}' explicit method implementation cannot implement `{1}' because it is an accessor",
                                                        member.GetSignatureForError (), TypeManager.CSharpSignature (implementing));
                                                return false;
                                        }
                                        method_name = member.InterfaceType.FullName + "." + name;
                                } else {
-                                       if (implementing != null && method is AbstractPropertyEventMethod && !implementing.IsSpecialName) {
-                                               Report.SymbolRelatedToPreviousError (implementing);
-                                               Report.Error (686, method.Location, "Accessor '{0}' cannot implement interface member '{1}' for type '{2}'. Use an explicit interface implementation",
-                                                       method.GetSignatureForError (container), TypeManager.CSharpSignature (implementing), container.GetSignatureForError ());
-                                               return false;
+                                       if (implementing != null) {
+                                               AbstractPropertyEventMethod prop_method = method as AbstractPropertyEventMethod;
+                                               if (prop_method != null) {
+                                                       if (!implementing.IsSpecialName) {
+                                                               Report.SymbolRelatedToPreviousError (implementing);
+                                                               Report.Error (686, method.Location, "Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use an explicit interface implementation",
+                                                                       method.GetSignatureForError (), TypeManager.CSharpSignature (implementing), container.GetSignatureForError ());
+                                                               return false;
+                                                       }
+                                                       PropertyBase.PropertyMethod pm = prop_method as PropertyBase.PropertyMethod;
+                                                       if (pm != null && pm.HasCustomAccessModifier && (pm.ModFlags & Modifiers.PUBLIC) == 0) {
+                                                               Report.SymbolRelatedToPreviousError (implementing);
+                                                               Report.Error (277, method.Location, "Accessor `{0}' must be declared public to implement interface member `{1}'",
+                                                                       method.GetSignatureForError (), TypeManager.CSharpSignature (implementing, true));
+                                                               return false;
+                                                       }
+                                               }
                                        }
                                }
                        }
@@ -4700,7 +4753,6 @@ namespace Mono.CSharp {
                                //
                                if ((modifiers & Modifiers.STATIC) != 0){
                                        implementing = null;
-                                       Modifiers.Error_InvalidModifier (method.Location, "static");
                                }
                        }
                        
@@ -4723,13 +4775,13 @@ namespace Mono.CSharp {
                                // Set Final unless we're virtual, abstract or already overriding a method.
                                if ((modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT | Modifiers.OVERRIDE)) == 0)
                                        flags |= MethodAttributes.Final;
-
-                               IsImplementing = true;
                        }
 
                        EmitContext ec = method.CreateEmitContext (container, null);
+                       if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute () != null)
+                               ec.TestObsoleteMethodUsage = false;
 
-                       DefineMethodBuilder (ec, container, method_name, ParameterTypes);
+                       DefineMethodBuilder (ec, container, method_name, method.ParameterInfo.Types);
 
                        if (builder == null)
                                return false;
@@ -4737,18 +4789,18 @@ namespace Mono.CSharp {
                        if ((modifiers & Modifiers.UNSAFE) != 0)
                                builder.InitLocals = false;
 
-                       if (IsImplementing){
+                       if (implementing != null){
                                //
                                // clear the pending implemntation flag
                                //
                                if (member is Indexer) {
                                        container.Pending.ImplementIndexer (
                                                member.InterfaceType, builder, method.ReturnType,
-                                               ParameterInfo, member.IsExplicitImpl);
+                                               method.ParameterInfo, member.IsExplicitImpl);
                                } else
                                        container.Pending.ImplementMethod (
                                                member.InterfaceType, name, method.ReturnType,
-                                               ParameterInfo, member.IsExplicitImpl);
+                                               method.ParameterInfo, member.IsExplicitImpl);
 
                                if (member.IsExplicitImpl)
                                        container.TypeBuilder.DefineMethodOverride (
@@ -4756,7 +4808,6 @@ namespace Mono.CSharp {
 
                        }
 
-                       TypeManager.RegisterMethod (builder, ParameterInfo, ParameterTypes);
                        TypeManager.AddMethod (builder, method);
 
                        return true;
@@ -4788,7 +4839,8 @@ namespace Mono.CSharp {
                                // We are more strict than Microsoft and report CS0626 like error
                                if (method.OptAttributes == null ||
                                        !method.OptAttributes.Contains (TypeManager.methodimpl_attr_type, ec)) {
-                                       Report.Error (626, method.Location, "Method, operator, or accessor '{0}' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation", method.GetSignatureForError (container));
+                                       Report.Error (626, method.Location, "Method, operator, or accessor `{0}' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation",
+                                               method.GetSignatureForError ());
                                        return;
                                }
                        }
@@ -4809,57 +4861,18 @@ namespace Mono.CSharp {
                        else
                                ec = method.CreateEmitContext (container, null);
 
-                       if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute (container) != null)
+                       if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute () != null)
                                ec.TestObsoleteMethodUsage = false;
 
-                       Location loc = method.Location;
+                       method.ParameterInfo.ApplyAttributes (ec, MethodBuilder);
+
                        Attributes OptAttributes = method.OptAttributes;
 
                        if (OptAttributes != null)
                                OptAttributes.Emit (ec, kind);
 
-                       if (member is MethodCore)
-                               ((MethodCore) member).Parameters.LabelParameters (ec, MethodBuilder, loc);
-
                        ToplevelBlock block = method.Block;
                        
-                       //
-                       // abstract or extern methods have no bodies
-                       //
-                       if ((modifiers & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0){
-                               if (block == null)
-                                       return;
-
-                               //
-                               // abstract or extern methods have no bodies.
-                               //
-                               if ((modifiers & Modifiers.ABSTRACT) != 0)
-                                       Report.Error (
-                                               500, method.Location, "Abstract method `" +
-                                               TypeManager.CSharpSignature (builder) +
-                                               "' can not have a body");
-
-                               if ((modifiers & Modifiers.EXTERN) != 0)
-                                       Report.Error (
-                                               179, method.Location, "External method `" +
-                                               TypeManager.CSharpSignature (builder) +
-                                               "' can not have a body");
-
-                               return;
-                       }
-
-                       //
-                       // Methods must have a body unless they're extern or abstract
-                       //
-                       if (block == null) {
-                               Report.Error (
-                                       501, method.Location, "Method `" +
-                                       TypeManager.CSharpSignature (builder) +
-                                       "' must declare a body since it is not marked " +
-                                       "abstract or extern");
-                               return;
-                       }
-
                        SourceMethod source = SourceMethod.Create (
                                container, MethodBuilder, method.Block);
 
@@ -4871,7 +4884,7 @@ namespace Mono.CSharp {
                        if (member is Destructor)
                                EmitDestructor (ec, block);
                        else
-                               ec.EmitTopBlock (block, ParameterInfo, loc);
+                               ec.EmitTopBlock (method, block);
 
                        if (source != null)
                                source.CloseMethod ();
@@ -4888,7 +4901,7 @@ namespace Mono.CSharp {
                        ig.BeginExceptionBlock ();
                        ec.ReturnLabel = finish;
                        ec.HasReturnLabel = true;
-                       ec.EmitTopBlock (block, null, method.Location);
+                       ec.EmitTopBlock (method, block);
                        
                        // ig.MarkLabel (finish);
                        ig.BeginFinallyBlock ();
@@ -4912,25 +4925,32 @@ namespace Mono.CSharp {
                }
        }
 
-       // Should derive from MethodCore
+       // TODO: Should derive from MethodCore
        public class Destructor : Method {
 
                public Destructor (TypeContainer ds, Expression return_type, int mod,
                                   string name, Parameters parameters, Attributes attrs,
                                   Location l)
-                       : base (ds, return_type, mod, false, new MemberName (name),
-                               parameters, attrs, l)
+                       : base (ds, return_type, mod, false, new MemberName (name, l),
+                               parameters, attrs)
                { }
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
                {
                        if (a.Type == TypeManager.conditional_attribute_type) {
-                               Report.Error (577, Location, "Conditional not valid on '{0}' because it is a destructor, operator, or explicit interface implementation", GetSignatureForError ());
+                               Report.Error (577, Location, "Conditional not valid on `{0}' because it is a constructor, destructor, operator or explicit interface implementation",
+                                       GetSignatureForError ());
                                return;
                        }
 
                        base.ApplyAttributeBuilder (a, cb);
                }
+
+               public override string GetSignatureForError ()
+               {
+                       return Parent.GetSignatureForError () + ".~" + Parent.MemberName.Name + "()";
+               }
+
        }
        
        abstract public class MemberBase : MemberCore {
@@ -4946,9 +4966,11 @@ namespace Mono.CSharp {
                //
                public string ShortName {
                        get { return MemberName.Name; }
-                       set {
-                               SetMemberName (new MemberName (MemberName.Left, value));
-                       }
+                       set { SetMemberName (new MemberName (MemberName.Left, value, Location)); }
+               }
+
+               public new TypeContainer Parent {
+                       get { return (TypeContainer) base.Parent; }
                }
 
                //
@@ -4963,8 +4985,9 @@ namespace Mono.CSharp {
                                        ec.InUnsafe = InUnsafe;
                                        Type = Type.ResolveAsTypeTerminal (ec, false);
                                        ec.InUnsafe = old_unsafe;
-
-                                       member_type = Type == null ? null : Type.Type;
+                                       if (Type != null) {
+                                               member_type = Type.Type;
+                                       }
                                }
                                return member_type;
                        }
@@ -4989,75 +5012,33 @@ namespace Mono.CSharp {
                // The constructor is only exposed to our children
                //
                protected MemberBase (TypeContainer parent, Expression type, int mod,
-                                     int allowed_mod, int def_mod, MemberName name,
-                                     Attributes attrs, Location loc)
-                       : base (parent, name, attrs, loc)
-               {
-                       explicit_mod_flags = mod;
-                       Type = type;
-                       ModFlags = Modifiers.Check (allowed_mod, mod, def_mod, loc);
-                       IsExplicitImpl = (MemberName.Left != null);
-               }
-
-               protected virtual bool CheckBase ()
-               {
-                       if ((ModFlags & Modifiers.PROTECTED) != 0 && Parent.Kind == Kind.Struct) {
-                               Report.Error (666, Location, "Protected member in struct declaration");
-                               return false;
-                       }
-   
-                       if ((RootContext.WarningLevel >= 4) &&
-                           ((Parent.ModFlags & Modifiers.SEALED) != 0) &&
-                           ((ModFlags & Modifiers.PROTECTED) != 0) &&
-                           ((ModFlags & Modifiers.OVERRIDE) == 0) && (Name != "Finalize")) {
-                               Report.Warning (628, Location, "'{0}': new protected member declared in sealed class", GetSignatureForError (Parent));
-                       }
-                       return true;
-               }
-
-               protected virtual bool CheckParameters (DeclSpace ds, Type [] parameters)
-               {
-                       bool error = false;
-
-                       foreach (Type partype in parameters){
-                               if (partype == TypeManager.void_type) {
-                                       Report.Error (
-                                               1547, Location, "Keyword 'void' cannot " +
-                                               "be used in this context");
-                                       return false;
-                               }
-
-                               if (partype.IsPointer){
-                                       if (!UnsafeOK (ds))
-                                               error = true;
-                                       if (!TypeManager.VerifyUnManaged (TypeManager.GetElementType (partype), Location))
-                                               error = true;
-                               }
-
-                               if (ds.AsAccessible (partype, ModFlags))
-                                       continue;
-
-                               if (this is Indexer)
-                                       Report.Error (55, Location,
-                                                     "Inconsistent accessibility: parameter type `" +
-                                                     TypeManager.CSharpName (partype) + "' is less " +
-                                                     "accessible than indexer `" + Name + "'");
-                               else if ((this is Method) && ((Method) this).IsOperator)
-                                       Report.Error (57, Location,
-                                                     "Inconsistent accessibility: parameter type `" +
-                                                     TypeManager.CSharpName (partype) + "' is less " +
-                                                     "accessible than operator `" + Name + "'");
-                               else
-                                       Report.Error (51, Location,
-                                                     "Inconsistent accessibility: parameter type `" +
-                                                     TypeManager.CSharpName (partype) + "' is less " +
-                                                     "accessible than method `" + Name + "'");
-                               error = true;
-                       }
-
-                       return !error;
+                                     int allowed_mod, int def_mod, MemberName name,
+                                     Attributes attrs)
+                       : base (parent, name, attrs)
+               {
+                       explicit_mod_flags = mod;
+                       Type = type;
+                       ModFlags = Modifiers.Check (allowed_mod, mod, def_mod, Location);
+                       IsExplicitImpl = (MemberName.Left != null);
                }
 
+               protected virtual bool CheckBase ()
+               {
+                       if ((ModFlags & Modifiers.PROTECTED) != 0 && Parent.Kind == Kind.Struct) {
+                               Report.Error (666, Location, "`{0}': new protected member declared in struct", GetSignatureForError ());
+                               return false;
+                       }
+   
+                       if ((RootContext.WarningLevel >= 4) &&
+                           ((Parent.ModFlags & Modifiers.SEALED) != 0) &&
+                           ((ModFlags & Modifiers.PROTECTED) != 0) &&
+                           ((ModFlags & Modifiers.OVERRIDE) == 0) && (Name != "Finalize")) {
+                               Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
+                       }
+                       return true;
+       }
+
+
                protected virtual bool DoDefine ()
                {
                        EmitContext ec = Parent.EmitContext;
@@ -5087,11 +5068,13 @@ namespace Mono.CSharp {
                        if (MemberType == null)
                                return false;
 
-                       if ((Parent.ModFlags & Modifiers.SEALED) != 0){
-                               if ((ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0){
-                                       Report.Error (549, Location, "Virtual method can not be contained in sealed class");
+                       CheckObsoleteType (Type);
+
+                       if ((Parent.ModFlags & Modifiers.SEALED) != 0 && 
+                               (ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0) {
+                                       Report.Error (549, Location, "New virtual member `{0}' is declared in a sealed class `{1}'",
+                                               GetSignatureForError (), Parent.GetSignatureForError ());
                                        return false;
-                               }
                        }
                        
                        // verify accessibility
@@ -5106,23 +5089,23 @@ namespace Mono.CSharp {
                                        Report.Error (54, Location,
                                                      "Inconsistent accessibility: indexer return type `" +
                                                      TypeManager.CSharpName (MemberType) + "' is less " +
-                                                     "accessible than indexer `" + Name + "'");
+                                                     "accessible than indexer `" + GetSignatureForError () + "'");
                                else if (this is MethodCore) {
                                        if (this is Operator)
                                                Report.Error (56, Location,
                                                              "Inconsistent accessibility: return type `" +
                                                              TypeManager.CSharpName (MemberType) + "' is less " +
-                                                             "accessible than operator `" + Name + "'");
+                                                             "accessible than operator `" + GetSignatureForError () + "'");
                                        else
                                                Report.Error (50, Location,
                                                              "Inconsistent accessibility: return type `" +
                                                              TypeManager.CSharpName (MemberType) + "' is less " +
-                                                             "accessible than method `" + Name + "'");
+                                                             "accessible than method `" + GetSignatureForError () + "'");
                                } else {
                                        Report.Error (52, Location,
                                                      "Inconsistent accessibility: field type `" +
                                                      TypeManager.CSharpName (MemberType) + "' is less " +
-                                                     "accessible than field `" + Name + "'");
+                                                     "accessible than field `" + GetSignatureForError () + "'");
                                }
                                return false;
                        }
@@ -5131,7 +5114,7 @@ namespace Mono.CSharp {
                                return false;
 
                        if (IsExplicitImpl) {
-                               Expression expr = MemberName.Left.GetTypeExpression (Location);
+                               Expression expr = MemberName.Left.GetTypeExpression ();
                                TypeExpr texpr = expr.ResolveAsTypeTerminal (ec, false);
                                if (texpr == null)
                                        return false;
@@ -5139,11 +5122,11 @@ namespace Mono.CSharp {
                                InterfaceType = texpr.ResolveType (ec);
 
                                if (!InterfaceType.IsInterface) {
-                                       Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
+                                       Report.Error (538, Location, "`{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
                                        return false;
                                }
                                
-                               if (!Parent.VerifyImplements (InterfaceType, ShortName, Name, Location))
+                               if (!Parent.VerifyImplements (this))
                                        return false;
                                
                                Modifiers.Check (Modifiers.AllowedExplicitImplFlags, explicit_mod_flags, 0, Location);
@@ -5152,15 +5135,10 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public override string GetSignatureForError (TypeContainer tc)
-               {
-                       return String.Concat (tc.Name, '.', base.GetSignatureForError (tc));
-               }
-
                protected bool IsTypePermitted ()
                {
                        if (MemberType == TypeManager.arg_iterator_type || MemberType == TypeManager.typed_reference_type) {
-                               Report.Error (610, Location, "Field or property cannot be of type '{0}'", TypeManager.CSharpName (MemberType));
+                               Report.Error (610, Location, "Field or property cannot be of type `{0}'", TypeManager.CSharpName (MemberType));
                                return false;
                        }
                        return true;
@@ -5172,16 +5150,12 @@ namespace Mono.CSharp {
                                return true;
                        }
 
-                       if (IsInterface && HasClsCompliantAttribute && ds.IsClsCompliaceRequired (ds)) {
-                               Report.Error (3010, Location, "'{0}': CLS-compliant interfaces must have only CLS-compliant members", GetSignatureForError ());
+                       if (IsInterface && HasClsCompliantAttribute && ds.IsClsComplianceRequired (ds)) {
+                               Report.Error (3010, Location, "`{0}': CLS-compliant interfaces must have only CLS-compliant members", GetSignatureForError ());
                        }
                        return false;
                }
 
-               protected override void VerifyObsoleteAttribute()
-               {
-                       CheckUsageOfObsoleteAttribute (MemberType);
-               }
        }
 
        //
@@ -5191,10 +5165,10 @@ namespace Mono.CSharp {
        abstract public class FieldBase : MemberBase {
                public FieldBuilder  FieldBuilder;
                public Status status;
+               protected Expression initializer;
 
                [Flags]
                public enum Status : byte {
-                       ASSIGNED = 1,
                        HAS_OFFSET = 4          // Used by FieldMember.
                }
 
@@ -5205,16 +5179,11 @@ namespace Mono.CSharp {
                /// </summary>
                public MemberInfo conflict_symbol;
 
-               //
-               // The constructor is only exposed to our children
-               //
                protected FieldBase (TypeContainer parent, Expression type, int mod,
-                                    int allowed_mod, MemberName name, object init,
-                                    Attributes attrs, Location loc)
+                                    int allowed_mod, MemberName name, Attributes attrs)
                        : base (parent, type, mod, allowed_mod, Modifiers.PRIVATE,
-                               name, attrs, loc)
+                               name, attrs)
                {
-                       this.init = init;
                }
 
                public override AttributeTargets AttributeTargets {
@@ -5241,48 +5210,43 @@ namespace Mono.CSharp {
                        FieldBuilder.SetCustomAttribute (cb);
                }
 
-               //
-               // Whether this field has an initializer.
-               //
-               public bool HasInitializer {
-                       get {
-                               return init != null;
-                       }
-               }
+               public void EmitInitializer (EmitContext ec)
+               {
+                       // Replace DeclSpace because of partial classes
+                       ec.DeclSpace = EmitContext.DeclSpace;
 
-               protected readonly Object init;
+                       ec.IsFieldInitializer = true;
+                       initializer = initializer.Resolve (ec);
+                       ec.IsFieldInitializer = false;
+                       if (initializer == null)
+                               return;
 
-               // Private.
-               Expression init_expr;
-               bool init_expr_initialized = false;
+                       FieldExpr fe = new FieldExpr (FieldBuilder, Location, true);
+                       if ((ModFlags & Modifiers.STATIC) == 0)
+                               fe.InstanceExpression = new This (Location).Resolve (ec);
 
-               //
-               // Resolves and returns the field initializer.
-               //
-               public Expression GetInitializerExpression (EmitContext ec)
-               {
-                       if (init_expr_initialized)
-                               return init_expr;
+                       ExpressionStatement a = new Assign (fe, initializer, Location);
 
-                       Expression e;
-                       if (init is Expression)
-                               e = (Expression) init;
-                       else
-                               e = new ArrayCreation (Type, "", (ArrayList)init, Location);
+                       a = a.ResolveStatement (ec);
+                       if (a == null)
+                               return;
+
+                       Constant c = initializer as Constant;
+                       if (c != null && CanElideInitializer (c))
+                               return;
 
-                       EmitContext parent_ec = Parent.EmitContext;
+                       a.EmitStatement (ec);
+               }
 
-                       bool old_is_static = parent_ec.IsStatic;
-                       parent_ec.IsStatic = ec.IsStatic;
-                       parent_ec.IsFieldInitializer = true;
-                       e = e.DoResolve (parent_ec);
-                       parent_ec.IsFieldInitializer = false;
-                       parent_ec.IsStatic = old_is_static;
+               bool CanElideInitializer (Constant c)
+               {
+                       if (MemberType == c.Type)
+                               return c.IsDefaultValue;
 
-                       init_expr = e;
-                       init_expr_initialized = true;
+                       if (c.Type == TypeManager.null_type)
+                               return true;
 
-                       return init_expr;
+                       return false;
                }
 
                protected override bool CheckBase ()
@@ -5297,25 +5261,27 @@ namespace Mono.CSharp {
                        conflict_symbol = Parent.FindBaseMemberWithSameName (Name, false);
                        if (conflict_symbol == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
-                                       Report.Warning (109, Location, "The member '{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError (Parent));
+                                       Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
                                }
                                return true;
                        }
  
                        if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE)) == 0) {
                                Report.SymbolRelatedToPreviousError (conflict_symbol);
-                               Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError (Parent));
+                               Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
+                                       GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
                        }
  
                        return true;
                }
 
-               public override string GetSignatureForError ()
-               {
-                       if (FieldBuilder == null) {
-                               return base.GetSignatureForError (Parent);
+               public Expression Initializer {
+                       set {
+                               if (value != null) {
+                                       this.initializer = value;
+                                       Parent.RegisterFieldForInitialization (this);
+                               }
                        }
-                       return TypeManager.GetFullNameSignature (FieldBuilder);
                }
 
                protected virtual bool IsFieldClsCompliant {
@@ -5339,7 +5305,7 @@ namespace Mono.CSharp {
                                return false;
 
                        if (!IsFieldClsCompliant) {
-                               Report.Error (3003, Location, "Type of '{0}' is not CLS-compliant", GetSignatureForError ());
+                               Report.Error (3003, Location, "Type of `{0}' is not CLS-compliant", GetSignatureForError ());
                        }
                        return true;
                }
@@ -5347,18 +5313,18 @@ namespace Mono.CSharp {
 
                public void SetAssigned ()
                {
-                       status |= Status.ASSIGNED;
+                       caching_flags |= Flags.IsAssigned;
                }
        }
 
-       public abstract class FieldMember: FieldBase
+       public abstract class FieldMember : FieldBase
        {
                protected FieldMember (TypeContainer parent, Expression type, int mod,
-                       int allowed_mod, MemberName name, object init, Attributes attrs, Location loc)
-                       : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, name, init, attrs, loc)
+                       int allowed_mod, MemberName name, Attributes attrs)
+                       : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, name, attrs)
                {
                        if ((mod & Modifiers.ABSTRACT) != 0)
-                               Report.Error (681, loc, "The modifier 'abstract' is not valid on fields. Try using a property instead");
+                               Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
                }
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
@@ -5395,9 +5361,11 @@ namespace Mono.CSharp {
                        if (ec == null)
                                throw new InternalErrorException ("FieldMember.Define called too early");
 
-                       if (MemberType == null)
+                       if (MemberType == null || Type == null)
                                return false;
 
+                       CheckObsoleteType (Type);
+
                        if (MemberType == TypeManager.void_type) {
                                Report.Error (1547, Location, "Keyword 'void' cannot be used in this context");
                                return false;
@@ -5410,7 +5378,7 @@ namespace Mono.CSharp {
                                Report.Error (52, Location,
                                        "Inconsistent accessibility: field type `" +
                                        TypeManager.CSharpName (MemberType) + "' is less " +
-                                       "accessible than field `" + Name + "'");
+                                       "accessible than field `" + GetSignatureForError () + "'");
                                return false;
                        }
 
@@ -5431,7 +5399,7 @@ namespace Mono.CSharp {
                        }
 
                        if (Parent.HasExplicitLayout && ((status & Status.HAS_OFFSET) == 0) && (ModFlags & Modifiers.STATIC) == 0) {
-                               Report.Error (625, Location, "'{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute.", GetSignatureForError ());
+                               Report.Error (625, Location, "`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute.", GetSignatureForError ());
                        }
 
                        base.Emit ();
@@ -5480,7 +5448,7 @@ namespace Mono.CSharp {
        /// <summary>
        /// Fixed buffer implementation
        /// </summary>
-       public class FixedField: FieldMember, IFixedBuffer
+       public class FixedField : FieldMember, IFixedBuffer
        {
                public const string FixedElementName = "FixedElementField";
                static int GlobalCounter = 0;
@@ -5501,10 +5469,10 @@ namespace Mono.CSharp {
 
                public FixedField (TypeContainer parent, Expression type, int mod, string name,
                        Expression size_expr, Attributes attrs, Location loc):
-                       base (parent, type, mod, AllowedModifiers, new MemberName (name), null, attrs, loc)
+                       base (parent, type, mod, AllowedModifiers, new MemberName (name, loc), attrs)
                {
                        if (RootContext.Version == LanguageVersion.ISO_1)
-                               Report.FeatureIsNotStandardized (loc, "fixed sized buffers");
+                               Report.FeatureIsNotStandardized (loc, "fixed size buffers");
 
                        this.size_expr = size_expr;
                }
@@ -5513,11 +5481,12 @@ namespace Mono.CSharp {
                {
 #if !NET_2_0
                        if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) != 0)
-                               Report.Warning (-23, Location, "Only private or internal fixed sized buffers are supported by .NET 1.x");
+                               Report.Warning (-23, 1, Location, "Only private or internal fixed sized buffers are supported by .NET 1.x");
 #endif
 
                        if (Parent.Kind != Kind.Struct) {
-                               Report.Error (1642, Location, "Fixed buffer fields may only be members of structs");
+                               Report.Error (1642, Location, "`{0}': Fixed size buffer fields may only be members of structs",
+                                       GetSignatureForError ());
                                return false;
                        }
 
@@ -5525,20 +5494,15 @@ namespace Mono.CSharp {
                                return false;
 
                        if (!TypeManager.IsPrimitiveType (MemberType)) {
-                               Report.Error (1663, Location, "Fixed sized buffer type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double");
+                               Report.Error (1663, Location, "`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double",
+                                       GetSignatureForError ());
                                return false;
                        }
 
-                       Expression e = size_expr.Resolve (Parent.EmitContext);
-                       if (e == null)
+                       Constant c = size_expr.ResolveAsConstant (Parent.EmitContext, this);
+                       if (c == null)
                                return false;
 
-                       Constant c = e as Constant;
-                       if (c == null) {
-                               Report.Error (133, Location, "The expression being assigned to '{0}' must be constant", GetSignatureForError ());
-                               return false;
-                       }
-
                        IntConstant buffer_size_const = c.ToInt (Location);
                        if (buffer_size_const == null)
                                return false;
@@ -5546,15 +5510,15 @@ namespace Mono.CSharp {
                        buffer_size = buffer_size_const.Value;
 
                        if (buffer_size <= 0) {
-                               Report.Error (1665, Location, "Fixed sized buffer '{0}' must have a length greater than zero", GetSignatureForError ());
+                               Report.Error (1665, Location, "`{0}': Fixed size buffers must have a length greater than zero", GetSignatureForError ());
                                return false;
                        }
 
                        int type_size = Expression.GetTypeSize (MemberType);
 
                        if (buffer_size > int.MaxValue / type_size) {
-                               Report.Error (1664, Location, "Fixed sized buffer of length '{0}' and type '{1}' exceeded 2^31 limit",
-                                       buffer_size.ToString (), TypeManager.CSharpName (MemberType));
+                               Report.Error (1664, Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit",
+                                       GetSignatureForError (), buffer_size.ToString (), TypeManager.CSharpName (MemberType));
                                return false;
                        }
 
@@ -5635,9 +5599,9 @@ namespace Mono.CSharp {
                        Modifiers.READONLY;
 
                public Field (TypeContainer parent, Expression type, int mod, string name,
-                             Object expr_or_array_init, Attributes attrs, Location loc)
-                       : base (parent, type, mod, AllowedModifiers, new MemberName (name),
-                               expr_or_array_init, attrs, loc)
+                             Attributes attrs, Location loc)
+                       : base (parent, type, mod, AllowedModifiers, new MemberName (name, loc),
+                               attrs)
                {
                }
 
@@ -5676,18 +5640,15 @@ namespace Mono.CSharp {
                                              (vt == TypeManager.char_type) ||
                                              (vt == TypeManager.float_type) ||
                                              (!vt.IsValueType))){
-                                               Report.Error (
-                                                       677, Location, Parent.MakeName (Name) +
-                                                       " A volatile field can not be of type `" +
-                                                       TypeManager.CSharpName (vt) + "'");
+                                               Report.Error (677, Location, "`{0}': A volatile field cannot be of the type `{1}'",
+                                                       GetSignatureForError (), TypeManager.CSharpName (vt));
                                                return false;
                                        }
                                }
 
                                if ((ModFlags & Modifiers.READONLY) != 0){
-                                       Report.Error (
-                                                     678, Location,
-                                                     "A field can not be both volatile and readonly");
+                                       Report.Error (678, Location, "`{0}': A field cannot be both volatile and readonly",
+                                               GetSignatureForError ());
                                        return false;
                                }
                        }
@@ -5710,8 +5671,20 @@ namespace Mono.CSharp {
                                TypeManager.RegisterFieldBase (FieldBuilder, this);
                        }
                        catch (ArgumentException) {
-                               Report.Warning (-24, Location, "The Microsoft runtime is unable to use [void|void*] as a field type, try using the Mono runtime.");
+                               Report.Warning (-24, 1, Location, "The Microsoft runtime is unable to use [void|void*] as a field type, try using the Mono runtime.");
+                               return false;
+                       }
+
+                       return true;
+               }
+
+               protected override bool VerifyClsCompliance (DeclSpace ds)
+               {
+                       if (!base.VerifyClsCompliance (ds))
                                return false;
+
+                       if ((ModFlags & Modifiers.VOLATILE) != 0) {
+                               Report.Warning (3026, 1, Location, "CLS-compliant field `{0}' cannot be volatile", GetSignatureForError ());
                        }
 
                        return true;
@@ -5721,7 +5694,7 @@ namespace Mono.CSharp {
        //
        // `set' and `get' accessors are represented with an Accessor.
        // 
-       public class Accessor {
+       public class Accessor : IIteratorContainer {
                //
                // Null if the accessor is empty, or a Block if not
                //
@@ -5735,6 +5708,7 @@ namespace Mono.CSharp {
                public Attributes Attributes;
                public Location Location;
                public int ModFlags;
+               public bool Yields;
                
                public Accessor (ToplevelBlock b, int mod, Attributes attrs, Location loc)
                {
@@ -5743,12 +5717,16 @@ namespace Mono.CSharp {
                        Location = loc;
                        ModFlags = Modifiers.Check (AllowedModifiers, mod, 0, loc);
                }
-       }
 
+               public void SetYields ()
+               {
+                       Yields = true;
+               }
+       }
 
        // Ooouh Martin, templates are missing here.
        // When it will be possible move here a lot of child code and template method type.
-       public abstract class AbstractPropertyEventMethod: MemberCore, IMethodData {
+       public abstract class AbstractPropertyEventMethod : MemberCore, IMethodData {
                protected MethodData method_data;
                protected ToplevelBlock block;
                protected ListDictionary declarative_security;
@@ -5763,7 +5741,7 @@ namespace Mono.CSharp {
                ReturnParameter return_attributes;
 
                public AbstractPropertyEventMethod (MemberBase member, string prefix)
-                       : base (null, SetupName (prefix, member), null, member.Location)
+                       : base (member.Parent, SetupName (prefix, member, member.Location), null)
                {
                        this.prefix = prefix;
                        IsDummy = true;
@@ -5771,21 +5749,21 @@ namespace Mono.CSharp {
 
                public AbstractPropertyEventMethod (MemberBase member, Accessor accessor,
                                                    string prefix)
-                       : base (null, SetupName (prefix, member),
-                               accessor.Attributes, accessor.Location)
+                       : base (member.Parent, SetupName (prefix, member, accessor.Location),
+                               accessor.Attributes)
                {
                        this.prefix = prefix;
                        this.block = accessor.Block;
                }
 
-               static MemberName SetupName (string prefix, MemberBase member)
+               static MemberName SetupName (string prefix, MemberBase member, Location loc)
                {
-                       return new MemberName (member.MemberName.Left, prefix + member.ShortName);
+                       return new MemberName (member.MemberName.Left, prefix + member.ShortName, loc);
                }
 
                public void UpdateName (MemberBase member)
                {
-                       SetMemberName (SetupName (prefix, member));
+                       SetMemberName (SetupName (prefix, member, Location));
                }
 
                #region IMethodData Members
@@ -5817,8 +5795,13 @@ namespace Mono.CSharp {
                        }
                }
 
-               public abstract ObsoleteAttribute GetObsoleteAttribute ();
-               public abstract Type[] ParameterTypes { get; }
+               public Type[] ParameterTypes { 
+                       get {
+                               return ParameterInfo.Types;
+                       }
+               }
+
+               public abstract Parameters ParameterInfo { get ; }
                public abstract Type ReturnType { get; }
                public abstract EmitContext CreateEmitContext(TypeContainer tc, ILGenerator ig);
 
@@ -5828,7 +5811,9 @@ namespace Mono.CSharp {
                {
                        if (a.Type == TypeManager.cls_compliant_attribute_type || a.Type == TypeManager.obsolete_attribute_type ||
                                        a.Type == TypeManager.conditional_attribute_type) {
-                               Report.Error (1667, a.Location, "'{0}' is not valid on property or event accessors. It is valid on {1} declarations only", TypeManager.CSharpName (a.Type), a.GetValidTargets ());
+                               Report.Error (1667, a.Location,
+                                       "Attribute `{0}' is not valid on property or event accessors. It is valid on `{1}' declarations only",
+                                       TypeManager.CSharpName (a.Type), a.GetValidTargets ());
                                return;
                        }
 
@@ -5883,14 +5868,14 @@ namespace Mono.CSharp {
                        method_data.Emit (container, this);
                }
 
-               public override bool IsClsCompliaceRequired(DeclSpace ds)
+               public override bool IsClsComplianceRequired(DeclSpace ds)
                {
                        return false;
                }
 
                public bool IsDuplicateImplementation (MethodCore method)
                {
-                       if (Name != method.Name)
+                       if (!MemberName.Equals (method.MemberName))
                                return false;
 
                        Type[] param_types = method.ParameterTypes;
@@ -5903,7 +5888,7 @@ namespace Mono.CSharp {
                                        return false;
 
                        Report.SymbolRelatedToPreviousError (method);
-                       Report.Error (111, Location, TypeContainer.Error111, method.Parent.GetSignatureForError (), Name);
+                       Report.Error (111, Location, TypeContainer.Error111, method.GetSignatureForError ());
                        return true;
                }
 
@@ -5930,10 +5915,6 @@ namespace Mono.CSharp {
                        get { throw new InvalidOperationException ("Unexpected attempt to get doc comment from " + this.GetType () + "."); }
                }
 
-               protected override void VerifyObsoleteAttribute()
-               {
-               }
-
        }
 
        //
@@ -5942,7 +5923,7 @@ namespace Mono.CSharp {
        //
        abstract public class PropertyBase : MethodCore {
 
-               public class GetMethod: PropertyMethod
+               public class GetMethod : PropertyMethod
                {
                        static string[] attribute_targets = new string [] { "method", "return" };
 
@@ -5960,7 +5941,7 @@ namespace Mono.CSharp {
                        {
                                base.Define (container);
                                
-                               method_data = new MethodData (method, method.ParameterInfo, ModFlags, flags, this);
+                               method_data = new MethodData (method, ModFlags, flags, this);
 
                                if (!method_data.Define (container))
                                        return null;
@@ -5968,17 +5949,18 @@ namespace Mono.CSharp {
                                return method_data.MethodBuilder;
                        }
 
-                       public override string GetSignatureForError (TypeContainer tc)
-                       {
-                               return String.Concat (base.GetSignatureForError (tc), ".get");
-                       }
-
                        public override Type ReturnType {
                                get {
                                        return method.MemberType;
                                }
                        }
 
+                       public override Parameters ParameterInfo {
+                               get {
+                                       return Parameters.EmptyReadOnlyParameters;
+                               }
+                       }
+
                        public override string[] ValidAttributeTargets {
                                get {
                                        return attribute_targets;
@@ -5986,10 +5968,11 @@ namespace Mono.CSharp {
                        }
                }
 
-               public class SetMethod: PropertyMethod {
+               public class SetMethod : PropertyMethod {
 
                        static string[] attribute_targets = new string [] { "method", "param", "return" };
                        ImplicitParameter param_attr;
+                       protected Parameters parameters;
 
                        public SetMethod (MethodCore method):
                                base (method, "set_")
@@ -6005,7 +5988,7 @@ namespace Mono.CSharp {
                        {
                                if (a.Target == AttributeTargets.Parameter) {
                                        if (param_attr == null)
-                                               param_attr = new ImplicitParameter (method_data.MethodBuilder);
+                                               param_attr = new ImplicitParameter (method_data.MethodBuilder, method.Location);
 
                                        param_attr.ApplyAttributeBuilder (a, cb);
                                        return;
@@ -6014,28 +5997,32 @@ namespace Mono.CSharp {
                                base.ApplyAttributeBuilder (a, cb);
                        }
 
-                       protected virtual InternalParameters GetParameterInfo (EmitContext ec)
+                       public override Parameters ParameterInfo {
+                               get {
+                                       return parameters;
+                               }
+                       }
+
+                       protected virtual void DefineParameters ()
                        {
                                Parameter [] parms = new Parameter [1];
-                               parms [0] = new Parameter (method.Type, "value", Parameter.Modifier.NONE, null);
-                               Parameters parameters = new Parameters (parms, null, method.Location);
-
-                               bool old_unsafe = ec.InUnsafe;
-                               ec.InUnsafe = InUnsafe;
-                               Type [] types = parameters.GetParameterInfo (ec);
-                               ec.InUnsafe = old_unsafe;
-
-                               return new InternalParameters (types, parameters);
+                               parms [0] = new Parameter (method.MemberType, "value", Parameter.Modifier.NONE, null, Location);
+                               parameters = new Parameters (parms);
+                               parameters.Resolve (null);
                        }
 
                        public override MethodBuilder Define (TypeContainer container)
                        {
                                if (container.EmitContext == null)
                                        throw new InternalErrorException ("SetMethod.Define called too early");
-                                       
+
+                               DefineParameters ();
+                               if (IsDummy)
+                                       return null;
+
                                base.Define (container);
-                               
-                               method_data = new MethodData (method, GetParameterInfo (container.EmitContext), ModFlags, flags, this);
+
+                               method_data = new MethodData (method, ModFlags, flags, this);
 
                                if (!method_data.Define (container))
                                        return null;
@@ -6043,17 +6030,6 @@ namespace Mono.CSharp {
                                return method_data.MethodBuilder;
                        }
 
-                       public override string GetSignatureForError (TypeContainer tc)
-                       {
-                               return String.Concat (base.GetSignatureForError (tc), ".set");
-                       }
-
-                       public override Type[] ParameterTypes {
-                               get {
-                                       return new Type[] { method.MemberType };
-                               }
-                       }
-
                        public override Type ReturnType {
                                get {
                                        return TypeManager.void_type;
@@ -6069,16 +6045,16 @@ namespace Mono.CSharp {
 
                static string[] attribute_targets = new string [] { "property" };
 
-               public abstract class PropertyMethod: AbstractPropertyEventMethod
+               public abstract class PropertyMethod : AbstractPropertyEventMethod
                {
                        protected readonly MethodCore method;
                        protected MethodAttributes flags;
+                       bool yields;
 
                        public PropertyMethod (MethodCore method, string prefix)
                                : base (method, prefix)
                        {
                                this.method = method;
-                               Parent = method.Parent;
                        }
 
                        public PropertyMethod (MethodCore method, Accessor accessor,
@@ -6086,11 +6062,11 @@ namespace Mono.CSharp {
                                : base (method, accessor, prefix)
                        {
                                this.method = method;
-                               Parent = method.Parent;
                                this.ModFlags = accessor.ModFlags;
+                               yields = accessor.Yields;
 
                                if (accessor.ModFlags != 0 && RootContext.Version == LanguageVersion.ISO_1) {
-                                       Report.FeatureIsNotStandardized (Location, "accessor modifiers");
+                                       Report.FeatureIsNotStandardized (Location, "access modifiers on properties");
                                }
                        }
 
@@ -6100,20 +6076,16 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override bool IsClsCompliaceRequired(DeclSpace ds)
-                       {
-                               return method.IsClsCompliaceRequired (ds);
-                       }
-
-                       public InternalParameters ParameterInfo 
+                       public override bool IsClsComplianceRequired(DeclSpace ds)
                        {
-                               get {
-                                       return method_data.ParameterInfo;
-                               }
+                               return method.IsClsComplianceRequired (ds);
                        }
 
                        public virtual MethodBuilder Define (TypeContainer container)
                        {
+                               if (!method.CheckAbstractAndExtern (block != null))
+                                       return null;
+
                                //
                                // Check for custom access modifier
                                //
@@ -6121,8 +6093,12 @@ namespace Mono.CSharp {
                                        ModFlags = method.ModFlags;
                                        flags = method.flags;
                                } else {
+                                       if (container.Kind == Kind.Interface)
+                                               Report.Error (275, Location, "`{0}': accessibility modifiers may not be used on accessors in an interface",
+                                                       GetSignatureForError ());
+
                                        if ((method.ModFlags & Modifiers.ABSTRACT) != 0 && (ModFlags & Modifiers.PRIVATE) != 0) {
-                                               Report.Error (442, Location, "{0}': abstract properties cannot have private accessors", GetSignatureForError (container));
+                                               Report.Error (442, Location, "`{0}': abstract properties cannot have private accessors", GetSignatureForError ());
                                        }
 
                                        CheckModifiers (container, ModFlags);
@@ -6132,8 +6108,17 @@ namespace Mono.CSharp {
                                        flags |= (method.flags & (~MethodAttributes.MemberAccessMask));
                                }
 
-                               return null;
+                               //
+                               // Setup iterator if we are one
+                               //
+                               if (yields) {
+                                       Iterator iterator = new Iterator (this, Parent as TypeContainer, ModFlags);
+                                       
+                                       if (!iterator.DefineIterator ())
+                                               return null;
+                               }
 
+                               return null;
                        }
 
                        public bool HasCustomAccessModifier
@@ -6143,12 +6128,6 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override Type[] ParameterTypes {
-                               get {
-                                       return TypeManager.NoTypes;
-                               }
-                       }
-
                        public override EmitContext CreateEmitContext (TypeContainer tc,
                                                                       ILGenerator ig)
                        {
@@ -6159,12 +6138,12 @@ namespace Mono.CSharp {
 
                        public override ObsoleteAttribute GetObsoleteAttribute ()
                        {
-                               return method.GetObsoleteAttribute (method.Parent);
+                               return method.GetObsoleteAttribute ();
                        }
 
-                       public override string GetSignatureForError (TypeContainer tc)
+                       public override string GetSignatureForError()
                        {
-                               return String.Concat (tc.Name, '.', method.Name);
+                               return method.GetSignatureForError () + '.' + prefix.Substring (0, 3);
                        }
                        
                        void CheckModifiers (TypeContainer container, int modflags)
@@ -6184,9 +6163,11 @@ namespace Mono.CSharp {
                                else if ((mflags & Modifiers.INTERNAL) != 0)
                                        flags |= Modifiers.PRIVATE;
 
-                               if ((mflags == modflags) || (modflags & (~flags)) != 0)
-                                       Report.Error (273, Location, "{0}: accessibility modifier must be more restrictive than the property or indexer",
-                                               GetSignatureForError (container));
+                               if ((mflags == modflags) || (modflags & (~flags)) != 0) {
+                                       Report.Error (273, Location,
+                                               "The accessibility modifier of the `{0}' accessor must be more restrictive than the modifier of the property or indexer `{1}'",
+                                               GetSignatureForError (), method.GetSignatureForError ());
+                               }
                        }
 
                        public override bool MarkForDuplicationCheck ()
@@ -6205,10 +6186,9 @@ namespace Mono.CSharp {
 
                public PropertyBase (TypeContainer ds, Expression type, int mod_flags,
                                     int allowed_mod, bool is_iface, MemberName name,
-                                    Parameters parameters, Attributes attrs,
-                                    Location loc)
+                                    Parameters parameters, Attributes attrs)
                        : base (ds, type, mod_flags, allowed_mod, is_iface, name,
-                               attrs, parameters, loc)
+                               attrs, parameters)
                {
                }
 
@@ -6248,7 +6228,7 @@ namespace Mono.CSharp {
                        // Accessors modifiers check
                        //
                        if (Get.ModFlags != 0 && Set.ModFlags != 0) {
-                               Report.Error (274, Location, "'{0}': cannot specify accessibility modifiers for both accessors of the property or indexer.",
+                               Report.Error (274, Location, "`{0}': Cannot specify accessibility modifiers for both accessors of the property or indexer",
                                                GetSignatureForError ());
                                return false;
                        }
@@ -6256,7 +6236,7 @@ namespace Mono.CSharp {
                        if ((Get.IsDummy || Set.IsDummy)
                                        && (Get.ModFlags != 0 || Set.ModFlags != 0) && (ModFlags & Modifiers.OVERRIDE) == 0) {
                                Report.Error (276, Location, 
-                                       "'{0}': accessibility modifiers on accessors may only be used if the property or indexer has both a get and a set accessor.",
+                                       "`{0}': accessibility modifiers on accessors may only be used if the property or indexer has both a get and a set accessor",
                                        GetSignatureForError ());
                                return false;
                        }
@@ -6270,14 +6250,6 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public override string GetSignatureForError()
-               {
-                       if (PropertyBuilder == null)
-                               return GetSignatureForError (Parent);
-
-                       return TypeManager.CSharpSignature (PropertyBuilder, false);
-               }
-
                protected override bool CheckForDuplications ()
                {
                        ArrayList ar = Parent.Indexers;
@@ -6322,18 +6294,20 @@ namespace Mono.CSharp {
                        if ((ModFlags & Modifiers.OVERRIDE) != 0) {
                                if (Get != null && !Get.IsDummy && get_accessor == null) {
                                        Report.SymbolRelatedToPreviousError (base_property);
-                                       Report.Error (545, Location, "'{0}': cannot override because '{1}' does not have an overridable get accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
+                                       Report.Error (545, Location, "`{0}.get': cannot override because `{1}' does not have an overridable get accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
                                }
 
                                if (Set != null && !Set.IsDummy && set_accessor == null) {
                                        Report.SymbolRelatedToPreviousError (base_property);
-                                       Report.Error (546, Location, "'{0}': cannot override because '{1}' does not have an overridable set accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
+                                       Report.Error (546, Location, "`{0}.set': cannot override because `{1}' does not have an overridable set accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
                                }
                        }
                        
                        //
                        // Check base class accessors access
                        //
+
+                       // TODO: rewrite to reuse Get|Set.CheckAccessModifiers and share code there
                        get_accessor_access = set_accessor_access = 0;
                        if ((ModFlags & Modifiers.NEW) == 0) {
                                if (get_accessor != null) {
@@ -6341,8 +6315,7 @@ namespace Mono.CSharp {
                                        get_accessor_access = (get_accessor.Attributes & MethodAttributes.MemberAccessMask);
 
                                        if (!Get.IsDummy && !CheckAccessModifiers (get_flags & MethodAttributes.MemberAccessMask, get_accessor_access, get_accessor))
-                                               Report.Error (507, Location, "'{0}' can't change the access modifiers when overriding inherited member '{1}'",
-                                                               GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
+                                               Error_CannotChangeAccessModifiers (get_accessor, get_accessor_access,  ".get");
                                }
 
                                if (set_accessor != null)  {
@@ -6350,8 +6323,7 @@ namespace Mono.CSharp {
                                        set_accessor_access = (set_accessor.Attributes & MethodAttributes.MemberAccessMask);
 
                                        if (!Set.IsDummy && !CheckAccessModifiers (set_flags & MethodAttributes.MemberAccessMask, set_accessor_access, set_accessor))
-                                               Report.Error (507, Location, "'{0}' can't change the access modifiers when overriding inherited member '{1}'",
-                                                               GetSignatureForError (container), TypeManager.GetFullNameSignature (base_property));
+                                               Error_CannotChangeAccessModifiers (set_accessor, set_accessor_access, ".set");
                                }
                        }
 
@@ -6406,18 +6378,6 @@ namespace Mono.CSharp {
                        Set.UpdateName (this);
                }
 
-               protected override bool VerifyClsCompliance (DeclSpace ds)
-               {
-                       if (!base.VerifyClsCompliance (ds))
-                               return false;
-
-                       if ((Get.ModFlags != ModFlags && !Get.IsDummy) || (Set.ModFlags != ModFlags && !Set.IsDummy)) {
-                               Report.Error (3025, Get.ModFlags != ModFlags ? Get.Location : Set.Location,
-                                       "CLS-compliant accessors must have the same accessibility as their property");
-                       }
-                       return true;
-               }
-
                public override string[] ValidAttributeTargets {
                        get {
                                return attribute_targets;
@@ -6432,7 +6392,7 @@ namespace Mono.CSharp {
                }
        }
                        
-       public class Property : PropertyBase, IIteratorContainer {
+       public class Property : PropertyBase {
                const int AllowedModifiers =
                        Modifiers.NEW |
                        Modifiers.PUBLIC |
@@ -6453,11 +6413,10 @@ namespace Mono.CSharp {
 
                public Property (TypeContainer ds, Expression type, int mod, bool is_iface,
                                 MemberName name, Attributes attrs, Accessor get_block,
-                                Accessor set_block, Location loc)
+                                Accessor set_block)
                        : base (ds, type, mod,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
-                               is_iface, name, Parameters.EmptyReadOnlyParameters, attrs,
-                               loc)
+                               is_iface, name, Parameters.EmptyReadOnlyParameters, attrs)
                {
                        if (get_block == null)
                                Get = new GetMethod (this);
@@ -6481,32 +6440,15 @@ namespace Mono.CSharp {
                        flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName;
 
                        if (!Get.IsDummy) {
-
                                GetBuilder = Get.Define (Parent);
                                if (GetBuilder == null)
                                        return false;
-
-                               //
-                               // Setup iterator if we are one
-                               //
-                               if ((ModFlags & Modifiers.METHOD_YIELDS) != 0){
-                                       Iterator iterator = new Iterator (
-                                               Parent, "get", MemberType,
-                                               Get.ParameterInfo,
-                                               ModFlags, Get.Block, Location);
-                                       
-                                       if (!iterator.DefineIterator ())
-                                               return false;
-                                       Get.Block = iterator.Block;
-                               }
                        }
 
+                       SetBuilder = Set.Define (Parent);
                        if (!Set.IsDummy) {
-                               SetBuilder = Set.Define (Parent);
                                if (SetBuilder == null)
                                        return false;
-
-                               SetBuilder.DefineParameter (1, ParameterAttributes.None, "value"); 
                        }
 
                        // FIXME - PropertyAttributes.HasDefault ?
@@ -6525,14 +6467,8 @@ namespace Mono.CSharp {
                        if (!Set.IsDummy)
                                PropertyBuilder.SetSetMethod (SetBuilder);
                        
-                       TypeManager.RegisterProperty (PropertyBuilder, GetBuilder, SetBuilder);
                        return true;
                }
-
-               public void SetYields ()
-               {
-                       ModFlags |= Modifiers.METHOD_YIELDS;
-               }
        }
 
        /// </summary>
@@ -6675,7 +6611,7 @@ namespace Mono.CSharp {
                public void SetUsed ()
                {
                        if (my_event != null) {
-                               my_event.status = FieldBase.Status.ASSIGNED;
+                               my_event.SetAssigned ();
                                my_event.SetMemberIsUsed ();
                        }
                }
@@ -6686,13 +6622,12 @@ namespace Mono.CSharp {
        /// </summary>
        public class EventProperty: Event {
 
-               static string[] attribute_targets = new string [] { "event", "property" };
+               static string[] attribute_targets = new string [] { "event" }; // "property" target was disabled for 2.0 version
 
                public EventProperty (TypeContainer parent, Expression type, int mod_flags,
-                                     bool is_iface, MemberName name, Object init,
-                                     Attributes attrs, Accessor add, Accessor remove,
-                                     Location loc)
-                       : base (parent, type, mod_flags, is_iface, name, init, attrs, loc)
+                                     bool is_iface, MemberName name,
+                                     Attributes attrs, Accessor add, Accessor remove)
+                       : base (parent, type, mod_flags, is_iface, name, attrs)
                {
                        Add = new AddDelegateMethod (this, add);
                        Remove = new RemoveDelegateMethod (this, remove);
@@ -6712,15 +6647,15 @@ namespace Mono.CSharp {
        /// <summary>
        /// Event is declared like field.
        /// </summary>
-       public class EventField: Event {
+       public class EventField : Event {
 
                static string[] attribute_targets = new string [] { "event", "field", "method" };
                static string[] attribute_targets_interface = new string[] { "event", "method" };
 
                public EventField (TypeContainer parent, Expression type, int mod_flags,
-                                  bool is_iface, MemberName name, Object init,
-                                  Attributes attrs, Location loc)
-                       : base (parent, type, mod_flags, is_iface, name, init, attrs, loc)
+                                  bool is_iface, MemberName name,
+                                  Attributes attrs)
+                       : base (parent, type, mod_flags, is_iface, name, attrs)
                {
                        Add = new AddDelegateMethod (this);
                        Remove = new RemoveDelegateMethod (this);
@@ -6742,6 +6677,22 @@ namespace Mono.CSharp {
                        base.ApplyAttributeBuilder (a, cb);
                }
 
+               public override bool Define()
+               {
+                       if (!base.Define ())
+                               return false;
+
+                       if (initializer != null) {
+                               if (((ModFlags & Modifiers.ABSTRACT) != 0)) {
+                                       Report.Error (74, Location, "`{0}': abstract event cannot have an initializer",
+                                               GetSignatureForError ());
+                                       return false;
+                               }
+                       }
+
+                       return true;
+               }
+
                public override string[] ValidAttributeTargets {
                        get {
                                return IsInterface ? attribute_targets_interface : attribute_targets;
@@ -6815,7 +6766,7 @@ namespace Mono.CSharp {
                        {
                                if (a.Target == AttributeTargets.Parameter) {
                                        if (param_attr == null)
-                                               param_attr = new ImplicitParameter (method_data.MethodBuilder);
+                                               param_attr = new ImplicitParameter (method_data.MethodBuilder, method.Location);
 
                                        param_attr.ApplyAttributeBuilder (a, cb);
                                        return;
@@ -6830,21 +6781,21 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       public override bool IsClsCompliaceRequired(DeclSpace ds)
+                       public override bool IsClsComplianceRequired(DeclSpace ds)
                        {
-                               return method.IsClsCompliaceRequired (ds);
+                               return method.IsClsComplianceRequired (ds);
                        }
 
-                       public MethodBuilder Define (TypeContainer container, InternalParameters ip)
+                       public MethodBuilder Define (TypeContainer container)
                        {
-                               method_data = new MethodData (method, ip, method.ModFlags,
+                               method_data = new MethodData (method, method.ModFlags,
                                        method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
 
                                if (!method_data.Define (container))
                                        return null;
 
                                MethodBuilder mb = method_data.MethodBuilder;
-                               mb.DefineParameter (1, ParameterAttributes.None, "value");
+                               ParameterInfo.ApplyAttributes (Parent.EmitContext, mb);
                                return mb;
                        }
 
@@ -6883,12 +6834,6 @@ namespace Mono.CSharp {
 
                        protected abstract MethodInfo DelegateMethodInfo { get; }
 
-                       public override Type[] ParameterTypes {
-                               get {
-                                       return new Type[] { method.MemberType };
-                               }
-                       }
-
                        public override Type ReturnType {
                                get {
                                        return TypeManager.void_type;
@@ -6903,14 +6848,9 @@ namespace Mono.CSharp {
                                        method.ModFlags, false);
                        }
 
-                       public override string GetSignatureForError (TypeContainer tc)
-                       {
-                               return String.Concat (tc.Name, '.', method.Name);
-                       }
-
                        public override ObsoleteAttribute GetObsoleteAttribute ()
                        {
-                               return method.GetObsoleteAttribute (method.Parent);
+                               return method.GetObsoleteAttribute ();
                        }
 
                        public override string[] ValidAttributeTargets {
@@ -6918,6 +6858,13 @@ namespace Mono.CSharp {
                                        return attribute_targets;
                                }
                        }
+
+                       public override Parameters ParameterInfo {
+                               get {
+                                       return method.parameters;
+                               }
+                       }
+
                }
 
 
@@ -6940,13 +6887,13 @@ namespace Mono.CSharp {
                public DelegateMethod Add, Remove;
                public MyEventBuilder     EventBuilder;
                public MethodBuilder AddBuilder, RemoveBuilder;
+               Parameters parameters;
 
-               public Event (TypeContainer parent, Expression type, int mod_flags,
-                             bool is_iface, MemberName name, Object init, Attributes attrs,
-                             Location loc)
+               protected Event (TypeContainer parent, Expression type, int mod_flags,
+                             bool is_iface, MemberName name, Attributes attrs)
                        : base (parent, type, mod_flags,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
-                               name, init, attrs, loc)
+                               name, attrs)
                {
                        IsInterface = is_iface;
                }
@@ -6979,16 +6926,9 @@ namespace Mono.CSharp {
 
                        if (!DoDefine ())
                                return false;
-
-                       if (init != null && ((ModFlags & Modifiers.ABSTRACT) != 0)){
-                               Report.Error (74, Location, "'" + Parent.Name + "." + Name +
-                                             "': abstract event can not have an initializer");
-                               return false;
-                       }
                        
                        if (!MemberType.IsSubclassOf (TypeManager.delegate_type)) {
-                               Report.Error (66, Location, "'" + Parent.Name + "." + Name +
-                                             "' : event must be of a delegate type");
+                               Report.Error (66, Location, "`{0}': event must be of a delegate type", GetSignatureForError ());
                                return false;
                        }
 
@@ -6999,10 +6939,9 @@ namespace Mono.CSharp {
                        ec.InUnsafe = InUnsafe;
 
                        Parameter [] parms = new Parameter [1];
-                       parms [0] = new Parameter (Type, "value", Parameter.Modifier.NONE, null);
-                       Parameters parameters = new Parameters (parms, null, Location);
-                       Type [] types = parameters.GetParameterInfo (ec);
-                       InternalParameters ip = new InternalParameters (types, parameters);
+                       parms [0] = new Parameter (MemberType, "value", Parameter.Modifier.NONE, null, Location);
+                       parameters = new Parameters (parms);
+                       parameters.Resolve (null);
 
                        ec.InUnsafe = old_unsafe;
 
@@ -7013,11 +6952,11 @@ namespace Mono.CSharp {
                        // Now define the accessors
                        //
 
-                       AddBuilder = Add.Define (Parent, ip);
+                       AddBuilder = Add.Define (Parent);
                        if (AddBuilder == null)
                                return false;
 
-                       RemoveBuilder = Remove.Define (Parent, ip);
+                       RemoveBuilder = Remove.Define (Parent);
                        if (RemoveBuilder == null)
                                return false;
 
@@ -7047,7 +6986,7 @@ namespace Mono.CSharp {
                        if (conflict_symbol != null && (ModFlags & Modifiers.NEW) == 0) {
                                if (!(conflict_symbol is EventInfo)) {
                                        Report.SymbolRelatedToPreviousError (conflict_symbol);
-                                       Report.Error (72, Location, "Event '{0}' can override only event", GetSignatureForError (Parent));
+                                       Report.Error (72, Location, "Event `{0}' can override only event", GetSignatureForError ());
                                        return false;
                                }
                        }
@@ -7071,10 +7010,7 @@ namespace Mono.CSharp {
 
                public override string GetSignatureForError ()
                {
-                       if (EventBuilder == null)
-                               return base.GetSignatureForError (Parent);
-
-                       return TypeManager.GetFullNameSignature (EventBuilder);
+                       return base.GetSignatureForError ();
                }
 
                //
@@ -7088,7 +7024,7 @@ namespace Mono.CSharp {
 
        public class Indexer : PropertyBase {
 
-               class GetIndexerMethod: GetMethod
+               class GetIndexerMethod : GetMethod
                {
                        public GetIndexerMethod (MethodCore method):
                                base (method)
@@ -7100,80 +7036,39 @@ namespace Mono.CSharp {
                        {
                        }
 
-                       // TODO: one GetSignatureForError is enough (reuse Parent member)
-                       public override string GetSignatureForError (TypeContainer tc)
-                       {
-                               string core = base.GetSignatureForError (tc);
-                               return core.Replace (TypeContainer.DefaultIndexerName, 
-                                       String.Format ("this[{0}]", TypeManager.CSharpName (ParameterTypes)));
-                       }
-
-                       public override Type[] ParameterTypes {
+                       public override Parameters ParameterInfo {
                                get {
-                                       return method.ParameterTypes;
+                                       return method.ParameterInfo;
                                }
                        }
                }
 
                class SetIndexerMethod: SetMethod
                {
-                       readonly Parameters parameters;
-
                        public SetIndexerMethod (MethodCore method):
                                base (method)
                        {
                        }
 
-                       public SetIndexerMethod (MethodCore method, Parameters parameters, Accessor accessor):
+                       public SetIndexerMethod (MethodCore method, Accessor accessor):
                                base (method, accessor)
                        {
-                               this.parameters = parameters;
-                       }
-
-                       public override Type[] ParameterTypes {
-                               get {
-                                       int top = method.ParameterTypes.Length;
-                                       Type [] set_pars = new Type [top + 1];
-                                       method.ParameterTypes.CopyTo (set_pars, 0);
-                                       set_pars [top] = method.MemberType;
-                                       return set_pars;
-                               }
                        }
 
-                       protected override InternalParameters GetParameterInfo (EmitContext ec)
+                       protected override void DefineParameters ()
                        {
-                               Parameter [] fixed_parms = parameters.FixedParameters;
-
-                               if (fixed_parms == null){
-                                       throw new Exception ("We currently do not support only array arguments in an indexer at: " + method.Location);
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       //
-                                       // Here is the problem: the `value' parameter has
-                                       // to come *after* the array parameter in the declaration
-                                       // like this:
-                                       // X (object [] x, Type value)
-                                       // .param [0]
-                                       //
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
-                                       
-                               }
-                               
+                               Parameter [] fixed_parms = method.Parameters.FixedParameters;
                                Parameter [] tmp = new Parameter [fixed_parms.Length + 1];
 
                                fixed_parms.CopyTo (tmp, 0);
                                tmp [fixed_parms.Length] = new Parameter (
-                                       method.Type, "value", Parameter.Modifier.NONE, null);
+                                       method.MemberType, "value", Parameter.Modifier.NONE, null, method.Location);
 
-                               Parameters set_formal_params = new Parameters (tmp, null, method.Location);
-                               Type [] types = set_formal_params.GetParameterInfo (ec);
-                               
-                               return new InternalParameters (types, set_formal_params);
+                               parameters = new Parameters (tmp);
+                               parameters.Resolve (null);
                        }
                }
 
-
                const int AllowedModifiers =
                        Modifiers.NEW |
                        Modifiers.PUBLIC |
@@ -7193,10 +7088,10 @@ namespace Mono.CSharp {
 
                public Indexer (TypeContainer ds, Expression type, MemberName name, int mod,
                                bool is_iface, Parameters parameters, Attributes attrs,
-                               Accessor get_block, Accessor set_block, Location loc)
+                               Accessor get_block, Accessor set_block)
                        : base (ds, type, mod,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
-                               is_iface, name, parameters, attrs, loc)
+                               is_iface, name, parameters, attrs)
                {
                        if (get_block == null)
                                Get = new GetIndexerMethod (this);
@@ -7206,7 +7101,7 @@ namespace Mono.CSharp {
                        if (set_block == null)
                                Set = new SetIndexerMethod (this);
                        else
-                               Set = new SetIndexerMethod (this, parameters, set_block);
+                               Set = new SetIndexerMethod (this, set_block);
                }
                       
                public override bool Define ()
@@ -7233,20 +7128,20 @@ namespace Mono.CSharp {
 
                                        if (IsExplicitImpl) {
                                                Report.Error (415, indexer_attr.Location,
-                                                             "The 'IndexerName' attribute is valid only on an " +
+                                                             "The `IndexerName' attribute is valid only on an " +
                                                              "indexer that is not an explicit interface member declaration");
                                                return false;
                                        }
 
                                        if ((ModFlags & Modifiers.OVERRIDE) != 0) {
                                                Report.Error (609, indexer_attr.Location,
-                                                             "Cannot set the 'IndexerName' attribute on an indexer marked override");
+                                                             "Cannot set the `IndexerName' attribute on an indexer marked override");
                                                return false;
                                        }
 
                                        if (!Tokenizer.IsValidIdentifier (ShortName)) {
                                                Report.Error (633, indexer_attr.Location,
-                                                             "The argument to the 'IndexerName' attribute must be a valid identifier");
+                                                             "The argument to the `IndexerName' attribute must be a valid identifier");
                                                return false;
                                        }
                                }
@@ -7272,8 +7167,8 @@ namespace Mono.CSharp {
                                        return false;
                        }
                        
+                       SetBuilder = Set.Define (Parent);
                        if (!Set.IsDummy){
-                               SetBuilder = Set.Define (Parent);
                                if (SetBuilder == null)
                                        return false;
                        }
@@ -7283,33 +7178,11 @@ namespace Mono.CSharp {
                        //
                        Parameter [] p = Parameters.FixedParameters;
                        if (p != null) {
+                               // TODO: should be done in parser and it needs to do cycle
                                if ((p [0].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
                                        Report.Error (631, Location, "ref and out are not valid in this context");
                                        return false;
                                }
-
-                               int i;
-                               
-                               for (i = 0; i < p.Length; ++i) {
-                                       if (!Get.IsDummy)
-                                               GetBuilder.DefineParameter (
-                                                       i + 1, p [i].Attributes, p [i].Name);
-
-                                       if (!Set.IsDummy)
-                                               SetBuilder.DefineParameter (
-                                                       i + 1, p [i].Attributes, p [i].Name);
-                               }
-
-                               if (!Set.IsDummy)
-                                       SetBuilder.DefineParameter (
-                                               i + 1, ParameterAttributes.None, "value");
-                                       
-                               if (i != ParameterTypes.Length) {
-                                       Parameter array_param = Parameters.ArrayParameter;
-
-                                       SetBuilder.DefineParameter (
-                                               i + 1, array_param.Attributes, array_param.Name);
-                               }
                        }
 
                        PropertyBuilder = Parent.TypeBuilder.DefineProperty (
@@ -7328,15 +7201,15 @@ namespace Mono.CSharp {
 
                public override string GetSignatureForError ()
                {
-                       if (PropertyBuilder == null)
-                               return GetSignatureForError (Parent);
-
-                       return TypeManager.CSharpSignature (PropertyBuilder, true);
-               }
+                       StringBuilder sb = new StringBuilder (Parent.GetSignatureForError ());
+                       if (MemberName.Left != null) {
+                               sb.Append ('.');
+                               sb.Append (MemberName.Left);
+                       }
 
-               public override string GetSignatureForError(TypeContainer tc)
-               {
-                       return String.Concat (tc.Name, ".this[", Parameters.FixedParameters [0].TypeName.ToString (), ']');
+                       sb.Append (".this");
+                       sb.Append (Parameters.GetSignatureForError ().Replace ('(', '[').Replace (')', ']'));
+                       return sb.ToString ();
                }
 
                public override bool MarkForDuplicationCheck ()
@@ -7344,7 +7217,6 @@ namespace Mono.CSharp {
                        caching_flags |= Flags.TestMethodDuplication;
                        return true;
                }
-
        }
 
        public class Operator : MethodCore, IIteratorContainer {
@@ -7390,7 +7262,10 @@ namespace Mono.CSharp {
 
                        // Implicit and Explicit
                        Implicit,
-                       Explicit
+                       Explicit,
+
+                       // Just because of enum
+                       TOP
                };
 
                public readonly OpType OperatorType;
@@ -7404,7 +7279,7 @@ namespace Mono.CSharp {
                                 int mod_flags, Parameters parameters,
                                 ToplevelBlock block, Attributes attrs, Location loc)
                        : base (parent, ret_type, mod_flags, AllowedModifiers, false,
-                               new MemberName ("op_" + type), attrs, parameters, loc)
+                               new MemberName ("op_" + type, loc), attrs, parameters)
                {
                        OperatorType = type;
                        Block = block;
@@ -7450,10 +7325,9 @@ namespace Mono.CSharp {
 
                public override bool Define ()
                {
-
                        const int RequiredModifiers = Modifiers.PUBLIC | Modifiers.STATIC;
                        if ((ModFlags & RequiredModifiers) != RequiredModifiers){
-                               Report.Error (558, Location, "User defined operators '{0}' must be declared static and public", GetSignatureForError (Parent));
+                               Report.Error (558, Location, "User-defined operator `{0}' must be declared static and public", GetSignatureForError ());
                                return false;
                        }
 
@@ -7467,10 +7341,10 @@ namespace Mono.CSharp {
 
                        OperatorMethod = new Method (
                                Parent, Type, ModFlags, false, MemberName,
-                               Parameters, OptAttributes, Location);
+                               Parameters, OptAttributes);
 
                        OperatorMethod.Block = Block;
-                       OperatorMethod.IsOperator = true;                       
+                       OperatorMethod.IsOperator = this;                       
                        OperatorMethod.flags |= MethodAttributes.SpecialName | MethodAttributes.HideBySig;
                        OperatorMethod.Define ();
 
@@ -7479,7 +7353,7 @@ namespace Mono.CSharp {
 
                        OperatorMethodBuilder = OperatorMethod.MethodBuilder;
 
-                       parameter_types = OperatorMethod.ParameterTypes;
+                       Type[] parameter_types = OperatorMethod.ParameterTypes;
                        Type declaring_type = OperatorMethodBuilder.DeclaringType;
                        Type return_type = OperatorMethod.ReturnType;
                        Type first_arg_type = parameter_types [0];
@@ -7491,11 +7365,8 @@ namespace Mono.CSharp {
                        
                        if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) {
                                if (first_arg_type == return_type && first_arg_type == declaring_type){
-                                       Report.Error (
-                                               555, Location,
-                                               "User-defined conversion cannot take an object of the " +
-                                               "enclosing type and convert to an object of the enclosing" +
-                                               " type");
+                                       Report.Error (555, Location,
+                                               "User-defined operator cannot take an object of the enclosing type and convert to an object of the enclosing type");
                                        return false;
                                }
                                
@@ -7517,20 +7388,20 @@ namespace Mono.CSharp {
                                }
 
                                if (first_arg_type.IsInterface || return_type.IsInterface){
-                                       Report.Error (
-                                               552, Location,
-                                               "User-defined conversion cannot convert to or from an " +
-                                               "interface type");
+                                       Report.Error (552, Location, "User-defined conversion `{0}' cannot convert to or from an interface type",
+                                               GetSignatureForError ());
                                        return false;
                                }
                                
                                if (first_arg_type.IsSubclassOf (return_type)
                                        || return_type.IsSubclassOf (first_arg_type)){
                                        if (declaring_type.IsSubclassOf (return_type)) {
-                                               Report.Error (553, Location, "'{0}' : user defined conversion to/from base class", GetSignatureForError ());
+                                               Report.Error (553, Location, "User-defined conversion `{0}' cannot convert to or from base class",
+                                                       GetSignatureForError ());
                                                return false;
                                        }
-                                       Report.Error (554, Location, "'{0}' : user defined conversion to/from derived class", GetSignatureForError ());
+                                       Report.Error (554, Location, "User-defined conversion `{0}' cannot convert to or from derived class",
+                                               GetSignatureForError ());
                                        return false;
                                }
                        } else if (OperatorType == OpType.LeftShift || OperatorType == OpType.RightShift) {
@@ -7538,7 +7409,7 @@ namespace Mono.CSharp {
                                        Report.Error (564, Location, "Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int");
                                        return false;
                                }
-                       } else if (Parameters.FixedParameters.Length == 1) {
+                       } else if (Parameters.Count == 1) {
                                // Checks for Unary operators
 
                                if (OperatorType == OpType.Increment || OperatorType == OpType.Decrement) {
@@ -7665,23 +7536,34 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override string GetSignatureForError (TypeContainer tc)
+               public static OpType GetOperatorType (string name)
                {
-                       StringBuilder sb = new StringBuilder ();
-                       sb.AppendFormat ("{0}.operator {1} {2}({3}", tc.Name, GetName (OperatorType), Type.Type == null ? Type.ToString () : TypeManager.CSharpName (Type.Type),
-                               Parameters.FixedParameters [0].GetSignatureForError ());
-                       
-                       if (Parameters.FixedParameters.Length > 1) {
-                               sb.Append (",");
-                               sb.Append (Parameters.FixedParameters [1].GetSignatureForError ());
+                       if (name.StartsWith ("op_")){
+                               for (int i = 0; i < Unary.oper_names.Length; ++i) {
+                                       if (Unary.oper_names [i] == name)
+                                               return (OpType)i;
+                               }
+
+                               for (int i = 0; i < Binary.oper_names.Length; ++i) {
+                                       if (Binary.oper_names [i] == name)
+                                               return (OpType)i;
+                               }
                        }
-                       sb.Append (")");
-                       return sb.ToString ();
+                       return OpType.TOP;
                }
 
                public override string GetSignatureForError ()
                {
-                       return ToString ();
+                       StringBuilder sb = new StringBuilder ();
+                       if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) {
+                               sb.AppendFormat ("{0}.{1} operator {2}", Parent.GetSignatureForError (), GetName (OperatorType), Type.Type == null ? Type.ToString () : TypeManager.CSharpName (Type.Type));
+                       }
+                       else {
+                               sb.AppendFormat ("{0}.operator {1}", Parent.GetSignatureForError (), GetName (OperatorType));
+                       }
+
+                       sb.Append (Parameters.GetSignatureForError ());
+                       return sb.ToString ();
                }
 
                public override bool MarkForDuplicationCheck ()
@@ -7690,38 +7572,11 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public override string ToString ()
-               {
-                       if (OperatorMethod == null)
-                               return Name;
-
-                       Type return_type = OperatorMethod.ReturnType;
-                       Type [] param_types = OperatorMethod.ParameterTypes;
-                       
-                       if (Parameters.FixedParameters.Length == 1)
-                               return String.Format (
-                                       "{0} operator {1}({2})",
-                                       TypeManager.CSharpName (return_type),
-                                       GetName (OperatorType),
-                                       param_types [0]);
-                       else
-                               return String.Format (
-                                       "{0} operator {1}({2}, {3})",
-                                       TypeManager.CSharpName (return_type),
-                                       GetName (OperatorType),
-                                       param_types [0], param_types [1]);
-               }
-
                public override string[] ValidAttributeTargets {
                        get {
                                return attribute_targets;
                        }
                }
-
-               public void SetYields ()
-               {
-                       ModFlags |= Modifiers.METHOD_YIELDS;
-               }
        }
 
        //
@@ -7828,7 +7683,7 @@ namespace Mono.CSharp {
 
                        Type [] args;
                        if (mi != null)
-                               args = TypeManager.GetArgumentTypes (mi);
+                               args = TypeManager.GetParameterData (mi).Types;
                        else
                                args = TypeManager.GetArgumentTypes (pi);
                        Type [] sigp = sig.Parameters;