Exemple #1
0
        void AddModuleDefinition(ModuleDefinition moduleDefinition, bool loadInternal, bool instantiateTypeParameter)
        {
            InstantiatedParamResolver resolver = new InstantiatedParamResolver();
            Module module = new Module(moduleDefinition);

            foreach (TypeDefinition type in moduleDefinition.Types)
            {
                if (!loadInternal && IsInternal(DomCecilType.GetModifiers(type.Attributes)))
                {
                    continue;
                }
//				if (type.Name == "SimplePropertyDescriptor")
//					System.Console.WriteLine(type.Attributes + "/" + DomCecilType.GetModifiers (type.Attributes) + "/" + IsInternal (DomCecilType.GetModifiers (type.Attributes)));
                DomCecilType loadType = new DomCecilType(type, loadInternal, loadMonotouchDocumentation);
                if (instantiateTypeParameter)
                {
                    resolver.Visit(loadType, null);
                    resolver.ClearTypes();
                }
                loadMonotouchDocumentation &= loadType.LoadMonotouchDocumentation;
                Add(loadType);
                module.Types.Add(loadType);
            }
            this.modules.Add(module);
        }
Exemple #2
0
        void AddModuleDefinition(ModuleDefinition moduleDefinition, bool loadInternal, bool instantiateTypeParameter)
        {
            InstantiatedParamResolver resolver = new InstantiatedParamResolver(xmlDocumentation);
            Module module = new Module(moduleDefinition);

            foreach (TypeDefinition type in moduleDefinition.Types)
            {
                // filter nested types, they're handled in DomCecilType.
                if ((type.Attributes & TypeAttributes.NestedPublic) == TypeAttributes.NestedPublic ||
                    (type.Attributes & TypeAttributes.NestedFamily) == TypeAttributes.NestedFamily ||
                    (type.Attributes & TypeAttributes.NestedAssembly) == TypeAttributes.NestedAssembly ||
                    (type.Attributes & TypeAttributes.NestedPrivate) == TypeAttributes.NestedPrivate ||
                    (type.Attributes & TypeAttributes.NestedFamANDAssem) == TypeAttributes.NestedFamANDAssem)
                {
                    continue;
                }
                if (!loadInternal && IsInternal(DomCecilType.GetModifiers(type.Attributes)))
                {
                    continue;
                }
//				if (type.Name == "SimplePropertyDescriptor")
//					System.Console.WriteLine(type.Attributes + "/" + DomCecilType.GetModifiers (type.Attributes) + "/" + IsInternal (DomCecilType.GetModifiers (type.Attributes)));
                DomCecilType loadType = new DomCecilType(type, loadInternal);
                if (instantiateTypeParameter)
                {
                    resolver.Visit(loadType, null);
                    resolver.ClearTypes();
                }
                Add(loadType);
                module.Types.Add(loadType);
            }
            this.modules.Add(module);
        }
/*		FieldDefinition fieldDefinition;
 *
 *              public FieldDefinition FieldDefinition {
 *                      get {
 *                              return fieldDefinition;
 *                      }
 *              }
 */

        public DomCecilField(FieldDefinition fieldDefinition)
        {
            base.name       = fieldDefinition.Name;
            base.Modifiers  = DomCecilType.GetModifiers(fieldDefinition);
            base.ReturnType = DomCecilMethod.GetReturnType(fieldDefinition.FieldType);
            DomCecilMethod.AddAttributes(this, fieldDefinition.CustomAttributes);
        }
Exemple #4
0
        public DomCecilMethod(MethodDefinition methodDefinition)
        {
            this.methodDefinition = methodDefinition;
            this.name             = methodDefinition.Name;
            if (methodDefinition.Name == ".ctor")
            {
                MethodModifier |= MethodModifier.IsConstructor;
            }

            foreach (GenericParameter param in methodDefinition.GenericParameters)
            {
                TypeParameter tp = new TypeParameter(param.FullName);
                tp.Variance = (TypeParameterVariance)(((uint)param.Attributes) & 3);

                if (param.HasDefaultConstructorConstraint)
                {
                    tp.TypeParameterModifier |= TypeParameterModifier.HasDefaultConstructorConstraint;
                }

                foreach (TypeReference tr in param.Constraints)
                {
                    tp.AddConstraint(DomCecilMethod.GetReturnType(tr));
                }
                AddTypeParameter(tp);
            }

            AddAttributes(this, methodDefinition.CustomAttributes);
            base.Modifiers  = DomCecilType.GetModifiers(methodDefinition);
            base.ReturnType = DomCecilMethod.GetReturnType(methodDefinition.ReturnType);
            foreach (ParameterDefinition paramDef in methodDefinition.Parameters)
            {
                Add(new DomCecilParameter(paramDef));
            }

            if (this.IsStatic)
            {
                foreach (IAttribute attr in this.Attributes)
                {
                    if (attr.Name == "System.Runtime.CompilerServices.ExtensionAttribute")
                    {
                        MethodModifier |= MethodModifier.IsExtension;
                        break;
                    }
                }
            }

            foreach (MethodReference overrideRef in methodDefinition.Overrides)
            {
                if (overrideRef.Name == this.name && IsPublic)
                {
                    continue;
                }
                AddExplicitInterface(GetReturnType(overrideRef.DeclaringType));
            }
        }
Exemple #5
0
 public DomCecilEvent(EventDefinition eventDefinition)
 {
     this.eventDefinition = eventDefinition;
     base.name            = eventDefinition.Name;
     base.Modifiers       = DomCecilType.GetModifiers(eventDefinition.AddMethod);
     base.ReturnType      = DomCecilMethod.GetReturnType(eventDefinition.EventType);
     DomCecilMethod.AddAttributes(this, eventDefinition.CustomAttributes);
     if (!eventDefinition.IsSpecialName)
     {
         base.Modifiers &= ~MonoDevelop.Projects.Dom.Modifiers.SpecialName;
     }
 }
Exemple #6
0
        void CheckInitialization()
        {
            if (isInitialized)
            {
                return;
            }
            isInitialized = true;

            foreach (FieldDefinition fieldDefinition in typeDefinition.Fields)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(fieldDefinition)))
                {
                    continue;
                }
                base.Add(new DomCecilField(fieldDefinition));
            }
            foreach (MethodDefinition methodDefinition in typeDefinition.Methods.Where(m => !m.IsConstructor))
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(methodDefinition)))
                {
                    continue;
                }
                base.Add(new DomCecilMethod(methodDefinition));
            }

            bool internalOnly    = true;
            bool hasConstructors = false;

            foreach (MethodDefinition methodDefinition in typeDefinition.Methods.Where(m => m.IsConstructor))
            {
                hasConstructors = true;
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(methodDefinition)))
                {
                    continue;
                }
                internalOnly = false;
                base.Add(new DomCecilMethod(methodDefinition));
            }
            if (hasConstructors && internalOnly)
            {
                base.TypeModifier |= TypeModifier.HasOnlyHiddenConstructors;
            }

            foreach (PropertyDefinition propertyDefinition in typeDefinition.Properties)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(propertyDefinition.Attributes)))
                {
                    continue;
                }
                base.Add(new DomCecilProperty(propertyDefinition));
            }
            foreach (EventDefinition eventDefinition in typeDefinition.Events)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(eventDefinition.Attributes)))
                {
                    continue;
                }
                base.Add(new DomCecilEvent(eventDefinition));
            }

            foreach (TypeDefinition nestedType in typeDefinition.NestedTypes)
            {
                if (!loadInternal && DomCecilCompilationUnit.IsInternal(DomCecilType.GetModifiers(nestedType.Attributes)))
                {
                    continue;
                }
                DomCecilType innerType = new DomCecilType(nestedType, loadInternal);
                base.Add(innerType);
                if (typeParameters != null && innerType.typeParameters != null)
                {
                    innerType.typeParameters.RemoveAll(para => typeParameters.Any(myPara => myPara.Name == para.Name));
                }
            }
        }