[Mono-list] Bug: FieldInfo.GetValue on literal field runs .cctor
Jeroen Frijters
jeroen@sumatra.nl
Thu, 18 Dec 2003 21:44:17 +0100
This is a multi-part message in MIME format.
------_=_NextPart_001_01C3C5A7.BF77CB89
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi,
Doing a FieldInfo.GetValue() on a literal field (a C# const) will
trigger the class constructor (.cctor) to run. .NET 1.0 & 1.1 do the
same, but Whidbey doesn't do this anymore.
I think the current Mono behavior is incorrect, it makes writing a
compiler using Reflection.Emit even harder than it already is ;-)
At the moment mcs triggers the class constructors in types in referenced
assemblies, if literal fields are accessed, this is obviously not a good
idea.
A proposed patch is attached.
Regards,
Jeroen
P.S. No, I'm not adding this to Bugzilla. I refuse to use a bug tracking
system that requires several weeks of study before it can be used.
------_=_NextPart_001_01C3C5A7.BF77CB89
Content-Type: application/octet-stream;
name="icall.diff"
Content-Transfer-Encoding: base64
Content-Description: icall.diff
Content-Disposition: attachment;
filename="icall.diff"
LS0tIG1vbm8vbW9uby9tZXRhZGF0YS9pY2FsbC5jCVRodSBEZWMgMTggMjE6MzI6MzYgMjAwMw0K
KysrIHNjcmF0Y2gvbW9uby0wLjI5L21vbm8vbWV0YWRhdGEvaWNhbGwuYwlXZWQgTm92IDI2IDE5
OjMzOjEwIDIwMDMNCkBAIC0xMjMyLDcgKzEyMzIsNyBAQA0KIAlpZiAoY2YtPnR5cGUtPmF0dHJz
ICYgRklFTERfQVRUUklCVVRFX1NUQVRJQykgew0KIAkJaXNfc3RhdGljID0gVFJVRTsNCiAJCXZ0
YWJsZSA9IG1vbm9fY2xhc3NfdnRhYmxlIChkb21haW4sIGZpZWxkLT5rbGFzcyk7DQotCQlpZiAo
IXZ0YWJsZS0+aW5pdGlhbGl6ZWQgJiYgKGNmLT50eXBlLT5hdHRycyAmIEZJRUxEX0FUVFJJQlVU
RV9MSVRFUkFMKSA9PSAwKQ0KKwkJaWYgKCF2dGFibGUtPmluaXRpYWxpemVkKQ0KIAkJCW1vbm9f
cnVudGltZV9jbGFzc19pbml0ICh2dGFibGUpOw0KIAl9DQogCQ0K
------_=_NextPart_001_01C3C5A7.BF77CB89--