bool DecodeCABlob(StringBuilder sb, ConstructorInfo constructor, byte[] blob, int level)
 {
     try
     {
         // CustomAttribute
         var br = new ByteReader(blob, 2, blob.Length - 4);
         ReadConstructorArguments(sb, br, constructor, level);
         br = new ByteReader(blob, blob.Length - (br.Length + 2), br.Length + 2);
         int named = br.ReadUInt16();
         if (constructor.GetParameters().Length != 0 && named != 0)
         {
             AppendNewLine(sb, level);
         }
         ReadNamedArguments(sb, br, named, level, false);
         return true;
     }
     catch (IKVM.Reflection.BadImageFormatException) { }
     catch (ArgumentOutOfRangeException) { }
     return false;
 }
 void ReadConstructorArguments(StringBuilder sb, ByteReader br, ConstructorInfo constructor, int level)
 {
     bool first = true;
     foreach (var parameter in constructor.GetParameters())
     {
         if (!first)
         {
             AppendNewLine(sb, level);
         }
         first = false;
         ReadFixedArg(sb, br, parameter.ParameterType);
     }
 }
Example #3
0
        IUnresolvedMethod ReadConstructor(ConstructorInfo method, IUnresolvedTypeDefinition parentType, EntityType methodType, IUnresolvedMember accessorOwner)
        {
            if (method == null)
                return null;
            var m = new DefaultUnresolvedMethod(parentType, method.Name);
            m.EntityType = methodType;
            m.AccessorOwner = accessorOwner;
            m.HasBody = method.GetMethodBody () != null;
            var genericArguments = method.GetGenericArguments ();
            if (genericArguments != null) {
                for (int i = 0; i < genericArguments.Length; i++) {
                    if (genericArguments[i].GenericParameterPosition != i)
                        throw new InvalidOperationException("g.Position != i");
                    m.TypeParameters.Add(new DefaultUnresolvedTypeParameter(
                        EntityType.Method, i, genericArguments[i].Name));
                }
                for (int i = 0; i < genericArguments.Length; i++) {
                    var tp = (DefaultUnresolvedTypeParameter)m.TypeParameters[i];
                    AddConstraints(tp, genericArguments[i]);
                    tp.ApplyInterningProvider(interningProvider);
                }
            }
            m.ReturnType = KnownTypeReference.Void;

            if (HasAnyAttributes(method))
                AddAttributes(method, m.Attributes, m.ReturnTypeAttributes);
            TranslateModifiers(method, m);

            foreach (var p in method.GetParameters ()) {
                m.Parameters.Add(ReadParameter(p));
            }

            FinishReadMember(m, method);
            return m;
        }