[Mono-devel-list]Re: [Mono-devel-list] [RFA, PATCH] Fix bug #57151

marek safar marek.safar at seznam.cz
Tue May 4 07:52:53 EDT 2004


Hi Hari,

+		public object GetPositionalValue (int i)
+		{
+			if (pos_values == null) return null;
+			return pos_values[i];
+		}
+

I prefer

return (pos_values == null) ? null : pos_values[i];


+
+		public override void ApplyAttributeBuilder (object builder, Attribute a, CustomAttributeBuilder cb)
+		{
+			if (a.Type == TypeManager.struct_layout_attribute_type
+			    && (LayoutKind) a.GetPositionalValue (0) == LayoutKind.Explicit) {
+				foreach (Field f in Fields) {
+					if ((f.ModFlags & Modifiers.STATIC) != 0)
+						continue;
+					if (f.OptAttributes == null
+					    || !f.OptAttributes.Contains (TypeManager.field_offset_attribute_type, this)) {
+						Report.Error (625, f.Location,
+							      "Instance field of type marked with " 
+							      + "StructLayout(LayoutKind.Explicit) must have a "
+							      + "FieldOffset attribute.");
+						return;
+					}
+				}
+			}
+			
+			base.ApplyAttributeBuilder (builder, a, cb);
+		}

is located in Struct class and it is wrong because StructLayoutAttribute can be apply to Struct and Class. I prefer to create new class in hierarchy between TypeContainer and Struct, Class and put a new class there. I think I will use it too.

Please, can you create error test (mcs\error\cs0652.cs).

Marek


> I have attached a patch that fixes bug #57151.
> 
> Ok to apply?
> 
> - Hari
> 

____________________________________________________________
Já jsem tady. Ukaž se ty! NOKIA 6100 již od 2977 Kč. www.oskar.cz
http://ad.seznam.cz/clickthru?spotId=74097&section=/



More information about the Mono-devel-list mailing list