[Mono-bugs] [Bug 430804] Static readonly field optimization doesn' t account for changes via reflection

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Nov 12 13:28:30 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=430804

User jonbnews at hotmail.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=430804#c6





--- Comment #6 from Jon Burgoyne <jonbnews at hotmail.com>  2008-11-12 11:28:29 MST ---
What I find strange is that this behavior only occurs for static readonly
fields.  If you try the above tests with non-static readonly fields, it works,
which means those fields aren't applying the same "readonly" behavior has their
static counterparts.  Why don't we do the same optimization for non-static
readonly fields?

I suspect the reason is that it would break all sorts of dependency injection
and mocking toolkits and paradigms.  If you want to use dependency injection,
it works by setting these values via reflection.  If references to those values
were optimized to contain the original readonly value, then dependency
injection wouldn't work.

Which is why I still think this bug is valid.  It's valid to do dependency
injection on static fields, but it won't work because of this issue.


-- 
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.


More information about the mono-bugs mailing list