public MethodInformation(MethodDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;

            if (def.HasBody)
            {
                foreach (var Inst in def.Body.Instructions)
                {
                    Instructions.Add(new InstructionInformation(Inst));
                }
                if (def.Body.HasVariables)
                {
                    foreach (var localVar in def.Body.Variables)
                    {
                        LocalVariables.Add(new VariableInformation(localVar, metadataContext));
                    }
                }
                if (def.HasParameters)
                {
                    foreach (ParameterDefinition param in def.Parameters)
                    {
                        Parameters.Add(new ParameterInformation(param, metadataContext));
                    }
                }
            }
        }
Пример #2
0
        public MethodInformation(MethodDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;

            if (def.HasBody)
            {
                foreach (var Inst in def.Body.Instructions)
                {
                    Instructions.Add(new InstructionInformation(Inst));
                }
                if (def.Body.HasVariables)
                {
                    foreach (var localVar in def.Body.Variables)
                    {
                        LocalVariables.Add(new VariableInformation(localVar, metadataContext));
                    }
                }
            }
            if (def.HasParameters)
            {
                foreach (ParameterDefinition param in def.Parameters)
                {
                    Parameters.Add(new ParameterInformation(param, metadataContext));
                }
            }
            if (def.HasGenericParameters)
            {
                genericParameterTypes = def.GenericParameters.Select(a => MetadataContext.GetTypeInformation(a)).ToArray();
            }
        }
Пример #3
0
        public TypeInformation(TypeDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;
            NamespaceChain       = def.Namespace.Split('.');

            foreach (var method in def.Methods)
            {
                var mtd = new MethodInformation(method, metadataContext);
                if (mtd.IsStaticConstructor)
                {
                    StaticConstructor = mtd;
                }
                Methods.Add(mtd);
            }
            foreach (var prop in def.Properties)
            {
                Properties.Add(new PropertyInformation(prop, metadataContext));
            }
            foreach (var field in def.Fields)
            {
                Fields.Add(new FieldInformation(field, metadataContext));
            }
            foreach (var nested in def.NestedTypes)
            {
                Nested.Add(new TypeInformation(nested, metadataContext));
            }


            this.genericParameterTypes = def.GenericParameters.Select(a => MetadataContext.GetTypeInformation(a)).ToArray();
            TypeAttributes             = def.Attributes.ToString().Split(sep, StringSplitOptions.RemoveEmptyEntries);
        }
Пример #4
0
        public FieldInformation(FieldDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;

            FieldType = def.FieldType.FullName;
            FullName  = def.FullName;
        }
Пример #5
0
        public TypeInformation(ArrayType def, MetadataContext metadataContext)
        {
            this.definitionArray = def;
            this.MetadataContext = metadataContext;
            var dd = definitionArray.ElementType;

            this.elementType = IsArray ? MetadataContext.GetTypeInformation(dd) : null;
        }
Пример #6
0
        public TypeInformation(PointerType def, MetadataContext metadataContext)
        {
            reference = def;
            this.definitionPointer = def;
            this.MetadataContext   = metadataContext;

            //var dd = definitionArray.ElementType;
            //this.elementType = IsArray ? MetadataContext.GetTypeInformation(dd) : null;
        }
Пример #7
0
        public AssemblyInformation(AssemblyDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;

            foreach (var module in def.Modules)
            {
                if (module.HasTypes)
                {
                    Modules.Add(module, new ModuleInformation(module, metadataContext));
                }
            }
        }
Пример #8
0
 public void SetupBaseAndInterface(MetadataContext metadataContext)
 {
     if (definition == null || IsGenericInstance)
     {
         return;
     }
     foreach (var Interface in definition.Interfaces)
     {
         Interfaces.Add(MetadataContext.GetTypeInformation(Interface.InterfaceType));
     }
     if (definition.BaseType != null)
     {
         BaseType = MetadataContext.GetTypeInformation(definition.BaseType);
     }
 }
Пример #9
0
        public TypeInformation(GenericInstanceType def, MetadataContext metadataContext)
        {
            reference            = def;
            this.definitionGI    = def;
            this.MetadataContext = metadataContext;
            var ElementType = metadataContext.GetTypeInformation(def.ElementType);

            this.genericElementType   = ElementType;
            this.genericArgumentTypes = def.GenericArguments.Select(a => MetadataContext.GetTypeInformation(a)).ToArray();
            this.definition           = ElementType.definition;
            Methods           = ElementType.Methods;
            StaticConstructor = ElementType.StaticConstructor;
            Properties        = ElementType.Properties;
            Fields            = ElementType.Fields;
            Nested            = ElementType.Nested;
            TypeAttributes    = ElementType.TypeAttributes;
        }
Пример #10
0
        public static MethodInformation GetMetaInformation(
            this MethodReference methodReference, MetadataContext context)
        {
            var type = context.GetTypeInformation(methodReference.DeclaringType);

            foreach (var mtdInfo in type.Methods)
            {
                if (mtdInfo.Definition is MethodReference mtdRef)
                {
                    if (mtdRef.Name == methodReference.Name)
                    {
                        return(mtdInfo);
                    }
                }
            }
            return(null);
        }
Пример #11
0
        public TypeInformation(TypeDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;

            NamespaceChain = def.Namespace.Split('.');

            foreach (var method in def.Methods)
            {
                Methods.Add(new MethodInformation(method, metadataContext));
            }
            foreach (var prop in def.Properties)
            {
                Properties.Add(new PropertyInformation(prop, metadataContext));
            }
            foreach (var field in def.Fields)
            {
                Fields.Add(new FieldInformation(field, metadataContext));
            }

            TypeAttributes = def.Attributes.ToString().Split(sep, StringSplitOptions.RemoveEmptyEntries);
        }
Пример #12
0
        public ModuleInformation(ModuleDefinition def, MetadataContext metadataContext)
        {
            this.definition      = def;
            this.MetadataContext = metadataContext;

            foreach (var type in definition.Types)
            {
                if (type.FullName != "<Module>")
                {
                    if (Types.ContainsKey(type.FullName))
                    {
                        Console.WriteLine(type.Module.Name
                                          + "!="
                                          + (Types[type.FullName].Definition as TypeDefinition).Module.Name
                                          );
                    }
                    else
                    {
                        Types.Add(type.FullName, new TypeInformation(type, metadataContext));
                    }
                }
            }
        }
Пример #13
0
 public ParameterInformation(ParameterDefinition defination, MetadataContext context)
 {
     this.MetadataContext = context;
     this.Definition      = defination;
 }
Пример #14
0
 public VariableInformation(VariableDefinition def, MetadataContext metadataContext)
 {
     Definition      = def;
     MetadataContext = metadataContext;
 }
Пример #15
0
 static MetadataContext()
 {
     // Initialize NetStandard.
     NetStandardMetadataContext = new MetadataContext("netstandard.dll", false);
 }
Пример #16
0
 public TypeInformation(GenericParameter def, MetadataContext metadataContext)
 {
     reference            = def;
     this.definitionGP    = def;
     this.MetadataContext = metadataContext;
 }
Пример #17
0
 public TypeInformation(TypeReference def, MetadataContext metadataContext)
 {
     this.reference       = def;
     this.MetadataContext = metadataContext;
 }
Пример #18
0
 public PropertyInformation(PropertyDefinition def, MetadataContext metadataContext)
 {
     this.definition      = def;
     this.MetadataContext = metadataContext;
 }