Re: [Ikvm-developers] Using C# attributes from Java
Brought to you by:
jfrijters
|
From: Michael B. <md...@sa...> - 2013-04-27 00:22:29
|
On Fri, Apr 26, 2013 at 5:02 PM, Michael Bayne <md...@sa...> wrote:
> then convert that to a DLL via IKVM, and then decompile the resulting DLL,
> I get a disassembly like so:
>
> .custom instance void class
> [mscorlib]System.ThreadStaticAttribute::'.ctor'() = (01 00 00 00 ) // ....
>
> which has both "instance void class" and quoted '.ctor'.
>
Yet more data:
I thought perhaps something was awry with attributes that take a string
argument, so I tried adding this to my test:
@cli.System.ObsoleteAttribute.Annotation("Another test")
public Foo () {
}
but that seems to work fine:
.custom instance void class
[mscorlib]System.ObsoleteAttribute::'.ctor'(string) = (
01 00 0C 41 6E 6F 74 68 65 72 20 74 65 73 74 00 // ...Another test.
00 ) // .
I also noticed something strange about the Java stub for System.Obsolete
versus MonoTouch.Foundation.Register:
public final class cli.System.ObsoleteAttribute extends
cli.System.Attribute implements
cli.System.Runtime.InteropServices._Attribute {
public cli.System.ObsoleteAttribute();
public cli.System.ObsoleteAttribute(java.lang.String);
public cli.System.ObsoleteAttribute(java.lang.String, boolean);
public final native java.lang.String get_Message();
public final native boolean get_IsError();
}
public interface cli.System.ObsoleteAttribute$Annotation extends
java.lang.annotation.Annotation {
public abstract java.lang.String value();
}
public final class cli.MonoTouch.Foundation.RegisterAttribute extends
cli.System.Attribute implements
cli.System.Runtime.InteropServices._Attribute {
public cli.MonoTouch.Foundation.RegisterAttribute();
public cli.MonoTouch.Foundation.RegisterAttribute(java.lang.String);
public cli.MonoTouch.Foundation.RegisterAttribute(java.lang.String,
boolean);
public final native java.lang.String get_Name();
public final native void set_Name(java.lang.String);
public final native boolean get_IsWrapper();
public final native void set_IsWrapper(boolean);
}
public interface cli.MonoTouch.Foundation.RegisterAttribute$Annotation
extends java.lang.annotation.Annotation {
public abstract java.lang.String value();
public abstract java.lang.String Name();
public abstract boolean IsWrapper();
}
It seems strange that the boolean IsError field is not exposed
in cli.System.ObsoleteAttribute$Annotation.
In any case, changing my test code to:
@cli.MonoTouch.Foundation.RegisterAttribute.Annotation(Name="Test",
IsWrapper=false)
public class Foo
does not impact the underlying issue. I still get an apparently bogus
disassembly:
.custom instance void
[monotouch]MonoTouch.Foundation.RegisterAttribute::.ctor() = (
01 00 02 00 54 0E 04 4E 61 6D 65 04 54 65 73 74 // ....T..Name.Test
54 02 09 49 73 57 72 61 70 70 65 72 00 ) // T..IsWrapper.
The quest continues...
-- md...@sa...
|