diff options
author | jfrijters <jfrijters> | 2011-11-25 16:47:17 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-11-25 16:47:17 +0400 |
commit | 4f6de4245eb0f84d7aa9a698208f242d1116491a (patch) | |
tree | ba07390270a5b1b70d84183b51891dd162f70cfd | |
parent | 050190d7820a202dccab2ca03dce34c938de0b09 (diff) |
Don't mangle property accessor method names, but use a custom modifier instead.
-rw-r--r-- | runtime/DynamicTypeWrapper.cs | 15 | ||||
-rw-r--r-- | runtime/TypeWrapper.cs | 6 | ||||
-rw-r--r-- | runtime/attributes.cs | 3 |
3 files changed, 13 insertions, 11 deletions
diff --git a/runtime/DynamicTypeWrapper.cs b/runtime/DynamicTypeWrapper.cs index 1704b512..db528575 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -4338,9 +4338,9 @@ namespace IKVM.Internal FieldAttributes attribs = fw.IsPublic ? FieldAttributes.Public : FieldAttributes.FamORAssem; attribs |= FieldAttributes.Static | FieldAttributes.Literal; - // we attach the (arbitrary) IsConst custom modifier because the C# compiler prefers fields without custom modifiers + // we attach the AccessStub custom modifier because the C# compiler prefers fields without custom modifiers // so if this class defines a field with the same name, that will be preferred over this one by the C# compiler - FieldBuilder fb = typeBuilder.DefineField(fw.Name, fw.FieldTypeWrapper.TypeAsSignatureType, null, new Type[] { JVM.Import(typeof(System.Runtime.CompilerServices.IsConst)) }, attribs); + FieldBuilder fb = typeBuilder.DefineField(fw.Name, fw.FieldTypeWrapper.TypeAsSignatureType, null, new Type[] { JVM.LoadType(typeof(IKVM.Attributes.AccessStub)) }, attribs); AttributeHelper.HideFromReflection(fb); fb.SetConstant(((ConstantFieldWrapper)fw).GetConstantValue()); } @@ -4358,12 +4358,17 @@ namespace IKVM.Internal AttributeHelper.SetModifiers(pb, fw.Modifiers, fw.IsInternal); } MethodAttributes attribs = fw.IsPublic ? MethodAttributes.Public : MethodAttributes.FamORAssem; - attribs |= MethodAttributes.HideBySig; + attribs |= MethodAttributes.HideBySig | MethodAttributes.SpecialName; if (fw.IsStatic) { attribs |= MethodAttributes.Static; } - MethodBuilder getter = typeBuilder.DefineMethod(wrapper.GenerateUniqueMethodName("get_" + fw.Name, propType, Type.EmptyTypes), attribs, propType, Type.EmptyTypes); + // we append the IKVM.Attributes.AccessStub type to the modopt array for use in the property accessor method signature + // to make sure they never conflict with any user defined methhods + Type[] modopt2 = modopt; + Array.Resize(ref modopt2, modopt2.Length + 1); + modopt2[modopt2.Length - 1] = JVM.LoadType(typeof(IKVM.Attributes.AccessStub)); + MethodBuilder getter = typeBuilder.DefineMethod("get_" + fw.Name, attribs, CallingConventions.Standard, propType, null, modopt2, Type.EmptyTypes, null, null); AttributeHelper.HideFromJava(getter); pb.SetGetMethod(getter); CodeEmitter ilgen = CodeEmitter.Create(getter); @@ -4382,7 +4387,7 @@ namespace IKVM.Internal attribs &= ~MethodAttributes.MemberAccessMask; attribs |= MethodAttributes.Private; } - MethodBuilder setter = typeBuilder.DefineMethod(wrapper.GenerateUniqueMethodName("set_" + fw.Name, Types.Void, new Type[] { propType }), attribs, null, new Type[] { propType }); + MethodBuilder setter = typeBuilder.DefineMethod("set_" + fw.Name, attribs, CallingConventions.Standard, null, null, null, new Type[] { propType }, null, new Type[][] { modopt2 }); AttributeHelper.HideFromJava(setter); pb.SetSetMethod(setter); ilgen = CodeEmitter.Create(setter); diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs index ef04d27b..534cdcec 100644 --- a/runtime/TypeWrapper.cs +++ b/runtime/TypeWrapper.cs @@ -812,12 +812,6 @@ namespace IKVM.Internal } } - internal static void SetNameSig(PropertyBuilder pb, string name, string sig) - { - CustomAttributeBuilder customAttributeBuilder = new CustomAttributeBuilder(typeofNameSigAttribute.GetConstructor(new Type[] { Types.String, Types.String }), new object[] { name, sig }); - pb.SetCustomAttribute(customAttributeBuilder); - } - internal static byte[] FreezeDryType(Type type) { System.IO.MemoryStream mem = new System.IO.MemoryStream(); diff --git a/runtime/attributes.cs b/runtime/attributes.cs index 3020968a..081a7fd4 100644 --- a/runtime/attributes.cs +++ b/runtime/attributes.cs @@ -786,4 +786,7 @@ namespace IKVM.Attributes return packages; } } + + // used in custom modifier for access stubs + public static class AccessStub { } } |