Disable few more tests
[mono.git] / mcs / mcs / field.cs
index 14998cd7965ccdb557136d12bd0239a8c876f235..46ca117aa42d80d473808aa27124d603a9f60090 100644 (file)
@@ -62,10 +62,8 @@ namespace Mono.CSharp
 
                static readonly string[] attribute_targets = new string [] { "field" };
 
-               protected FieldBase (DeclSpace parent, FullNamedExpression type, Modifiers mod,
-                                    Modifiers allowed_mod, MemberName name, Attributes attrs)
-                       : base (parent, null, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE,
-                               name, attrs)
+               protected FieldBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
+                       : base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, name, attrs)
                {
                        if ((mod & Modifiers.ABSTRACT) != 0)
                                Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
@@ -94,6 +92,12 @@ namespace Mono.CSharp
                        }
                }
 
+               public string Name {
+                       get {
+                               return MemberName.Name;
+                       }
+               }
+
                public FieldSpec Spec {
                        get {
                                return spec;
@@ -115,8 +119,7 @@ namespace Mono.CSharp
 
                        declarators.Add (declarator);
 
-                       // TODO: This will probably break
-                       Parent.AddMember (this, declarator.Name.Value);
+                       Parent.AddNameToContainer (this, declarator.Name.Value);
                }
 
                public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
@@ -230,12 +233,14 @@ namespace Mono.CSharp
                {
                        if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
                                Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder);
-                       } else if (!(Parent is CompilerGeneratedClass) && member_type.HasDynamicElement) {
+                       } else if (!Parent.IsCompilerGenerated && member_type.HasDynamicElement) {
                                Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder, member_type, Location);
                        }
 
                        if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
                                Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (FieldBuilder);
+                       if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
+                               Module.PredefinedAttributes.DebuggerBrowsable.EmitAttribute (FieldBuilder, System.Diagnostics.DebuggerBrowsableState.Never);
 
                        if (OptAttributes != null) {
                                OptAttributes.Emit ();
@@ -372,7 +377,7 @@ namespace Mono.CSharp
                        Modifiers.PRIVATE |
                        Modifiers.UNSAFE;
 
-               public FixedField (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
+               public FixedField (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
                        : base (parent, type, mod, AllowedModifiers, name, attrs)
                {
                }
@@ -404,12 +409,12 @@ namespace Mono.CSharp
                                        GetSignatureForError ());
                        } else if (declarators != null) {
                                var t = new TypeExpression (MemberType, TypeExpression.Location);
-                               int index = Parent.PartialContainer.Fields.IndexOf (this);
                                foreach (var d in declarators) {
                                        var f = new FixedField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
                                        f.initializer = d.Initializer;
                                        ((ConstInitializer) f.initializer).Name = d.Name.Value;
-                                       Parent.PartialContainer.Fields.Insert (++index, f);
+                                       f.Define ();
+                                       Parent.PartialContainer.Members.Add (f);
                                }
                        }
                        
@@ -569,8 +574,7 @@ namespace Mono.CSharp
                        Modifiers.UNSAFE |
                        Modifiers.READONLY;
 
-               public Field (DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name,
-                             Attributes attrs)
+               public Field (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
                        : base (parent, type, mod, AllowedModifiers, name, attrs)
                {
                }
@@ -632,19 +636,18 @@ namespace Mono.CSharp
                        }
 
                        if (initializer != null) {
-                               ((TypeContainer) Parent).RegisterFieldForInitialization (this,
-                                       new FieldInitializer (spec, initializer, this));
+                               Parent.RegisterFieldForInitialization (this, new FieldInitializer (this, initializer, TypeExpression.Location));
                        }
 
                        if (declarators != null) {
-                               var t = new TypeExpression (MemberType, TypeExpression.Location);
-                               int index = Parent.PartialContainer.Fields.IndexOf (this);
                                foreach (var d in declarators) {
+                                       var t = new TypeExpression (MemberType, d.Name.Location);
                                        var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
                                        if (d.Initializer != null)
                                                f.initializer = d.Initializer;
 
-                                       Parent.PartialContainer.Fields.Insert (++index, f);
+                                       f.Define ();
+                                       Parent.PartialContainer.Members.Add (f);
                                }
                        }