[Ikvm-developers] Using C# attributes from Java
Brought to you by:
jfrijters
|
From: Michael B. <md...@sa...> - 2013-04-26 23:49:16
|
I'm trying to use a C# attribute on a Java class (which is used by
MonoTouch for some under the hood magic which AFAIK is based on C#
reflection, so it shouldn't be too crazy).
If I write my class in C# like so:
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate {
(where Register is MonoTouch.Foundation.Register). Then I get a disassembly
(from monodis) that looks like this:
.custom instance void class
[monotouch]MonoTouch.Foundation.RegisterAttribute::'.ctor'(string) = (
01 00 0B 41 70 70 44 65 6C 65 67 61 74 65 00 00 ) //
...AppDelegate..
If I write my class in Java like so:
@RegisterAttribute.Annotation("AppDelegate")
public class AppDelegate extends UIApplicationDelegate {
and then convert it to a DLL via IKVM, I get a disassembly that looks like
this:
.custom instance void
[monotouch]MonoTouch.Foundation.RegisterAttribute::.ctor(string) = (
01 00 0B 41 70 70 44 65 6C 65 67 61 74 65 00 00 ) //
...AppDelegate..
I'll admit to not knowing the first thing about how C# attributes work, but
the two things that jump out are, from C# I get "instance void class
...RegisterAttribute" and from Java/IKVM I get only "instance void
...RegisterAttribute", which seems like it could be causing problems.
There's also the issue that from C# the '.ctor' method is quoted and from
Java/IKVM it's not.
I should also point out that this is using IKVM 0.46.0.1, which I know is
woefully out of date, so if this is a known issue that has been fixed long
since, feel free to tell me to shut the hell up and update my
MonoTouch-compatible IKVM fork.
Thanks!
Michael
-- md...@sa...
|