[Mono-bugs] [Bug 82490][Min] Changed - ContextStatic variable initializer doesn't work

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Aug 20 10:04:49 EDT 2007

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 jan.oravec at 6com.sk.


--- shadow/82490	2007-08-20 08:52:18.000000000 -0400
+++ shadow/82490.tmp.27208	2007-08-20 10:04:49.000000000 -0400
@@ -173,6 +173,38 @@
 see http://www.yoda.arachsys.com/csharp/beforefieldinit.html
 This is "by design" as well and not-a-bug. You can repro it
 w/out contexts.
+------- Additional Comments From jan.oravec at 6com.sk  2007-08-20 10:04 -------
+Thanks for good pointer and sorry for taking your time with not-a-bugs.
+I do not think it is related to beforefieldinit, as initializer should
+still be called before access.
+I think it has something to do with initializer dependency resolution,
+as changing order of static variables helped. Mono appears to run
+initializers in code order, even if there is a dependency. The
+following code writes 'true':
+class A { }
+class B
+  public static A foo = goo;
+  public static A goo = new A ();
+class C
+  public static void Main ()
+  {
+    System.Console.WriteLine (B.foo == null);
+  }
+I would expect some dependency resolution, but I am not sure about C#
+specification. Not reopening as I am not sure if this is a bug or feature.

More information about the mono-bugs mailing list