Bugzilla – Bug 319848
Static and non static properties
Last modified: 2011-03-30 08:24:21 UTC
---- Reported by mono@evain.net 2005-12-19 18:15:53 MST ---- mcs emits the same propertyinfo for static and non static properties. class Test { public static string A { get { return ""; } } public string B { get { return ""; } } } For this code, mcs emits the same property signature. The first one should have it's hasThis bit set to one in the CallingConvention. Additional Information: The problem is that there is no way in the current S.R.E API to define whether an PropertyBuilder is an instance property or a class one. This leads to bugs like #77040. ---- Additional Comments From rharinath@novell.com 2005-12-20 03:16:22 MST ---- Is there a way to deduce that? Will a heuristic like the following work: if the get_S method is static, then S is static ---- Additional Comments From rharinath@novell.com 2005-12-20 03:17:37 MST ---- I mean: apply the heuristic in SRE.PropertyBuilder.SetGetMethod -- in this case #77040 will likely continue to fail, but for a different reason. ---- Additional Comments From mono@evain.net 2005-12-20 03:36:49 MST ---- According to the spec the CLS says that if all the methods of the property are instance methods, it's an instance property. If not it's a class one. Maybe we can check on both SetGetMethod and SetSetMethod ? ---- Additional Comments From rharinath@novell.com 2005-12-20 04:04:11 MST ---- Sounds good. Anyway, not much we can do to mcs... --> CORLIB ---- Additional Comments From mono@evain.net 2005-12-20 04:09:22 MST ---- I'm not sure mcs can't do anything. At stated in https://bugzilla.novell.com/show_bug.cgi?id=MONO77040, MS's SRE always emits static properties. Can we imagine a private corlib methods called in the same way we did for resource embedding ?
In .NET 2.0 SP1, MS introduced a new DefineProperty overload on TypeBuilder that allows the calling convention to be set. We can use that one for gmcs. For mcs, we'll need to mark that method as internal and invoke it using reflection.
*** Bug 373190 has been marked as a duplicate of this bug. ***
Hey Marek, has this been fixed? Can we close it?
I should be but I am waiting for Cecil upgrade in master to test it.
Already fixed in master