public IUnresolvedAttribute ReadAttribute(CustomAttributeData attribute) { if (attribute == null) throw new ArgumentNullException("attribute"); var ctor = attribute.Constructor; ITypeReference attributeType = ReadTypeReference(attribute.AttributeType); IList<ITypeReference> ctorParameterTypes = EmptyList<ITypeReference>.Instance; var parameters = ctor.GetParameters (); if (parameters.Length > 0) { ctorParameterTypes = new ITypeReference[parameters.Length]; for (int i = 0; i < ctorParameterTypes.Count; i++) { ctorParameterTypes[i] = ReadTypeReference(parameters[i].ParameterType); } ctorParameterTypes = interningProvider.InternList(ctorParameterTypes); } return interningProvider.Intern(new CecilUnresolvedAttribute(attributeType, ctorParameterTypes, attribute.__GetBlob ())); }
public ReflectionAttributeMap(Attribute attribute) { _attribute = attribute; }
public IUnresolvedAttribute ReadAttribute(CustomAttributeData attribute) { if (attribute == null) throw new ArgumentNullException("attribute"); var ctor = attribute.Constructor; ITypeReference attributeType = ReadTypeReference(attribute.AttributeType); IList<ITypeReference> ctorParameterTypes = EmptyList<ITypeReference>.Instance; var parameters = ctor.GetParameters (); if (parameters.Length > 0) { ctorParameterTypes = new ITypeReference[parameters.Length]; for (int i = 0; i < ctorParameterTypes.Count; i++) { ctorParameterTypes[i] = ReadTypeReference(parameters[i].ParameterType); } ctorParameterTypes = interningProvider.InternList(ctorParameterTypes); } byte[] blob; try { blob = attribute.__GetBlob (); } catch (Exception e) { blob = new byte[0]; Console.Error.WriteLine ("IKVM error while getting blob:" + e); } return interningProvider.Intern(new UnresolvedAttributeBlob(attributeType, ctorParameterTypes, blob)); }
decimal? TryDecodeDecimalConstantAttribute(CustomAttributeData attribute) { if (attribute.ConstructorArguments.Count != 5) return null; var reader = new BlobReader(attribute.__GetBlob(), null); if (reader.ReadUInt16() != 0x0001) { Debug.WriteLine("Unknown blob prolog"); return null; } // DecimalConstantAttribute has the arguments (byte scale, byte sign, uint hi, uint mid, uint low) or (byte scale, byte sign, int hi, int mid, int low) // Both of these invoke the Decimal constructor (int lo, int mid, int hi, bool isNegative, byte scale) with explicit argument conversions if required. var ctorArgs = new object[attribute.ConstructorArguments.Count]; for (int i = 0; i < ctorArgs.Length; i++) { switch (attribute.ConstructorArguments[i].ArgumentType.FullName) { case "System.Byte": ctorArgs[i] = reader.ReadByte(); break; case "System.Int32": ctorArgs[i] = reader.ReadInt32(); break; case "System.UInt32": ctorArgs[i] = unchecked((int)reader.ReadUInt32()); break; default: return null; } } if (!ctorArgs.Select(a => a.GetType()).SequenceEqual(new[] { typeof(byte), typeof(byte), typeof(int), typeof(int), typeof(int) })) return null; return new decimal((int)ctorArgs[4], (int)ctorArgs[3], (int)ctorArgs[2], (byte)ctorArgs[1] != 0, (byte)ctorArgs[0]); }
static void Process(MethodBase method, IKVM.Reflection.Type returnType, CustomAttributeData attrData) { string returnTypeString = returnType == TypeManager.VoidType ? "void" : TypeToC(returnType); string unmanagedMethodName = method.Name.Replace(".", "_"); var namedArguments = attrData.NamedArguments ?? new CustomAttributeNamedArgument[0]; foreach (var arg in namedArguments) { if (arg.MemberInfo.Name == "ReturnType") returnTypeString = arg.TypedValue.Value.ToString(); else if (arg.MemberInfo.Name == "Name") unmanagedMethodName = arg.TypedValue.Value.ToString(); } var paramList = new List<string>(); if (!method.IsStatic) { // Add *this* parameter paramList.Add(FormatParameter( "MonoObject*", TypeToString(method.DeclaringType), "self" )); } foreach (var info in method.GetParameters()) { paramList.Add(FormatParameter( TypeToC(info.ParameterType), TypeToString(info.ParameterType), info.Name )); } paramList.Add("MonoObject **ex"); string qualMethodName = String.Format("{0}_{1}", method.DeclaringType.Name, unmanagedMethodName); string qualMethodDecl = String.Format("{0} (THUNKCALL *{1})({2});", returnTypeString, qualMethodName, String.Join(", ", paramList)); currentMethods.Add(new ThunkMethodInfo( method.Name, qualMethodName, qualMethodDecl, method.ToString(), method.IsGenericMethodDefinition)); }
public List <CustomAttributeData> __GetCustomAttributesFor(int token) { return(CustomAttributeData.GetCustomAttributesImpl(new List <CustomAttributeData>(), this, token, null)); }
public IList <CustomAttributeData> GetCustomAttributesData() { return(CustomAttributeData.GetCustomAttributes(this)); }
public IList <CustomAttributeData> __GetCustomAttributes(Type attributeType, bool inherit) { return(CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit)); }
public bool IsDefined(Type attributeType, bool inherit) { return(CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0); }