예제 #1
0
 DmdMethodBodyReader(IMethodBodyResolver methodBodyResolver, DmdDataStream reader, IList <DmdType> genericTypeArguments, IList <DmdType> genericMethodArguments)
 {
     this.methodBodyResolver     = methodBodyResolver ?? throw new ArgumentNullException(nameof(methodBodyResolver));
     this.reader                 = reader ?? throw new ArgumentNullException(nameof(reader));
     this.genericTypeArguments   = genericTypeArguments ?? Array.Empty <DmdType>();
     this.genericMethodArguments = genericMethodArguments ?? Array.Empty <DmdType>();
 }
예제 #2
0
		DmdCustomAttributeReader(DmdModule module, DmdDataStream reader, DmdType ctorReflectedType, IList<DmdType> genericTypeArguments, bool ownsReader) {
			this.module = module;
			this.reader = reader;
			this.ctorReflectedType = ctorReflectedType;
			this.genericTypeArguments = genericTypeArguments;
			this.ownsReader = ownsReader;
			recursionCounter = 0;
		}
예제 #3
0
 public static DmdMethodBody Create(IMethodBodyResolver methodBodyResolver, DmdDataStream reader, IList <DmdType> genericTypeArguments, IList <DmdType> genericMethodArguments)
 {
     try {
         return(new DmdMethodBodyReader(methodBodyResolver, reader, genericTypeArguments, genericMethodArguments).Read());
     }
     catch (IOException) {
     }
     catch (OutOfMemoryException) {
     }
     return(null);
 }
예제 #4
0
		public static DmdCustomAttributeData Read(DmdModule module, DmdDataStream stream, DmdConstructorInfo ctor) {
			using (var reader = new DmdCustomAttributeReader(module, stream, ctor.ReflectedType, GetGenericArguments(ctor.ReflectedType), ownsReader: true)) {
				try {
					return reader.Read(ctor);
				}
				catch (CABlobParserException) {
				}
				catch (ResolveException) {
				}
				catch (IOException) {
				}
				return null;
			}
		}
예제 #5
0
 DmdMarshalBlobReader(DmdModule module, DmdDataStream reader, IList <DmdType> genericTypeArguments)
 {
     this.module = module;
     this.reader = reader;
     this.genericTypeArguments = genericTypeArguments ?? Array.Empty <DmdType>();
 }
예제 #6
0
 public static DmdMarshalType Read(DmdModule module, DmdDataStream reader, IList <DmdType> genericTypeArguments)
 {
     using (var marshalReader = new DmdMarshalBlobReader(module, reader, genericTypeArguments))
         return(marshalReader.Read());
 }
예제 #7
0
 public static            DmdCustomAttributeData[] Read(DmdModule module, DmdDataStream signature, SecurityAction action, IList <DmdType> genericTypeArguments)
 {
     using (var reader = new DmdDeclSecurityReader(module, signature, genericTypeArguments))
         return(reader.Read(action));
 }
예제 #8
0
 public static            DmdCustomAttributeData[] Read(DmdModule module, DmdDataStream signature, SecurityAction action) => Read(module, signature, action, null);
예제 #9
0
		internal static DmdCustomAttributeNamedArgument[] ReadNamedArguments(DmdModule module, DmdDataStream stream, DmdType ctorReflectedType, int numNamedArgs, IList<DmdType> genericTypeArguments) {
			using (var reader = new DmdCustomAttributeReader(module, stream, ctorReflectedType, genericTypeArguments, ownsReader: false)) {
				try {
					return reader.ReadNamedArguments(numNamedArgs);
				}
				catch (CABlobParserException) {
				}
				catch (ResolveException) {
				}
				catch (IOException) {
				}
				return null;
			}
		}
예제 #10
0
 DmdDeclSecurityReader(DmdModule module, DmdDataStream reader, IList <DmdType>?genericTypeArguments)
 {
     this.reader = reader;
     this.module = module;
     this.genericTypeArguments = genericTypeArguments ?? Array.Empty <DmdType>();
 }
예제 #11
0
 public static (DmdType fieldType, DmdMethodSignature methodSignature, bool containedGenericParams) ReadMethodSignatureOrFieldType(DmdModule module, DmdDataStream reader, IList <DmdType> genericTypeArguments, IList <DmdType> genericMethodArguments, bool resolve)
 {
     try {
         using (var sigReader = new DmdSignatureReader(module, reader, genericTypeArguments, genericMethodArguments, resolve)) {
             var flags = (DmdSignatureCallingConvention)reader.ReadByte();
             if ((flags & DmdSignatureCallingConvention.Mask) == DmdSignatureCallingConvention.Field)
             {
                 var fieldType = sigReader.ReadType().type;
                 return(fieldType, null, sigReader.containedGenericParams);
             }
             else
             {
                 sigReader.ReadMethodSignature(flags, out var genericParameterCount, out var returnType, out var parameterTypes, out var varArgsParameterTypes);
                 if ((flags & DmdSignatureCallingConvention.Mask) != DmdSignatureCallingConvention.Property)
                 {
                     var methodSignature = new DmdMethodSignature(flags, genericParameterCount, returnType, parameterTypes, varArgsParameterTypes);
                     return(null, methodSignature, sigReader.containedGenericParams);
                 }
             }
         }
     }
     catch (IOException) {
     }
     catch (OutOfMemoryException) {
     }
     return(module.AppDomain.System_Void, null, false);
 }
예제 #12
0
        public static (DmdMethodSignature methodSignature, bool containedGenericParams) ReadMethodSignature(DmdModule module, DmdDataStream reader, IList <DmdType> genericTypeArguments, IList <DmdType> genericMethodArguments, bool isProperty, bool resolve)
        {
            try {
                using (var sigReader = new DmdSignatureReader(module, reader, genericTypeArguments, genericMethodArguments, resolve)) {
                    sigReader.ReadMethodSignature(out var flags, out var genericParameterCount, out var returnType, out var parameterTypes, out var varArgsParameterTypes);
                    if (((flags & DmdSignatureCallingConvention.Mask) == DmdSignatureCallingConvention.Property) == isProperty)
                    {
                        var methodSignature = new DmdMethodSignature(flags, genericParameterCount, returnType, parameterTypes, varArgsParameterTypes);
                        return(methodSignature, sigReader.containedGenericParams);
                    }
                }
            }
            catch (IOException) {
            }
            catch (OutOfMemoryException) {
            }
            var dummySig = new DmdMethodSignature(isProperty ? DmdSignatureCallingConvention.Property : DmdSignatureCallingConvention.Default, 0, module.AppDomain.System_Void, null, null);

            return(dummySig, false);
        }
예제 #13
0
 public static (DmdType fieldType, bool containedGenericParams) ReadFieldSignature(DmdModule module, DmdDataStream reader, IList <DmdType> genericTypeArguments, bool resolve)
 {
     try {
         using (var sigReader = new DmdSignatureReader(module, reader, genericTypeArguments, null, resolve)) {
             var fieldType = sigReader.ReadFieldSignature();
             return(fieldType, sigReader.containedGenericParams);
         }
     }
     catch (IOException) {
     }
     catch (OutOfMemoryException) {
     }
     return(module.AppDomain.System_Void, false);
 }
예제 #14
0
 public static (DmdType[] types, bool containedGenericParams) ReadMethodSpecSignature(DmdModule module, DmdDataStream reader, IList <DmdType> genericTypeArguments, IList <DmdType> genericMethodArguments, bool resolve)
 {
     try {
         using (var sigReader = new DmdSignatureReader(module, reader, genericTypeArguments, genericMethodArguments, resolve)) {
             var types = sigReader.ReadInstantiation();
             return(types, sigReader.containedGenericParams);
         }
     }
     catch (IOException) {
     }
     catch (OutOfMemoryException) {
     }
     return(Array.Empty <DmdType>(), false);
 }