https://bugzilla.novell.com/show_bug.cgi?id=430804
User [EMAIL PROTECTED] added comment https://bugzilla.novell.com/show_bug.cgi?id=430804#c5 --- Comment #5 from Paolo Molaro <[EMAIL PROTECTED]> 2008-09-30 14:22:26 MDT --- The spec explicitly says: "initonly marks fields which are constant after they are initialized" (16.1.2 Field contract attributes). It doesn't talk about any compile-time behavior (in fact this is the spec about the file format, not about any compiler). Let me know in what way "are constant after they are initialized" is not clear. What you're seeing is simply an optimization that the MS jit apparently isn't doing for some reason and your code will break when they'll implement it for your case. Using reflection to update an initonly field is legitimate (and in fact it works perfectly well in mono) but it is a workaround, the same way you can use reflection to change a private field of another type. There is no reason to reject setting these fields with reflection, think about the private flag, it is the same, the only difference is that by setting the initonly flag you're telling the jit that (in the spec words) the field is "constant" once the ctor returns. I suggest you fix your code, but if you're poking inside an assembly that you don't own you could run mono with specific optimization flags and live with either the slowdown or with broken code. For your case you'd need to use: mono --O=shared test.exe -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. You are the assignee for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
