[Mono-bugs] [Bug 47904][Nor] New - StructLayoutAttribute applied to child class of parent without attribute
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 26 Aug 2003 01:35:32 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by vladimir@pobox.com.
http://bugzilla.ximian.com/show_bug.cgi?id=47904
--- shadow/47904 2003-08-26 01:35:32.000000000 -0400
+++ shadow/47904.tmp.15246 2003-08-26 01:35:32.000000000 -0400
@@ -0,0 +1,65 @@
+Bug#: 47904
+Product: Mono/Runtime
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: vladimir@pobox.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: StructLayoutAttribute applied to child class of parent without attribute
+
+This could be a bug in the MS runtime; it could also be a spec issue.
+
+Sample program:
+
+----- t9.cs -----
+using System;
+using System.Runtime.InteropServices;
+
+public class Foo { }
+
+[StructLayoutAttribute(LayoutKind.Sequential)]
+public class Bar : Foo { }
+
+public class Driver {
+ public static void Main () {
+ Bar b = new Bar();
+ }
+}
+----- end -----
+
+Under mono/mcs, this compiles and runs fine. Under the 1.1 .NET runtime,
+it compiles without errors, but gives:
+
+Unhandled exception: System.TypeLoadException: Could not load type Bar from
+assembly t, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null because
+the format is invalid.
+ at Driver.Main()
+
+If the StructLayoutAttribute is applied to class Bar as well, then all
+works well. So, this is either:
+
+1) A bug in mono's type loader that doesn't catch this inconsistency (I'm
+not sure what "sequential" means in a derived class if the parent class
+isn't also explicitly sequential; however, for myself, I need it to mean
+that GetFields() will return the class fields in the order they were declared)
+
+2) A bug in the .NET CLR that doesn't handle this correctly
+
+And also quite possibly:
+
+3) A bug in the spec; I couldn't find any information on whether this
+situation is even legal.
+
+It's usually a non-issue; however, MarshalByRefObject and
+ContextBoundObject don't have the Sequential attribute applied, so under
+the MS CLR, anything that derivces from these cannot have a
+StructLayoutAttribute applied.