void AddCommentTags(ICompilationUnit cu, ArrayList tagComments)
 {
     foreach (ICSharpCode.SharpRefactory.Parser.VB.TagComment tagComment in tagComments) {
         DefaultRegion tagRegion = new DefaultRegion(tagComment.StartPosition.Y, tagComment.StartPosition.X);
         MonoDevelop.Internal.Parser.Tag tag = new MonoDevelop.Internal.Parser.Tag(tagComment.Tag, tagRegion);
         tag.CommentString = tagComment.CommentText;
         cu.TagComments.Add(tag);
     }
 }
        /*		string GetIndexerName(PropertyInfo propertyInfo)
        {
            StringBuilder propertyName = new StringBuilder("Item(");
            ParameterInfo[] p = propertyInfo.GetIndexParameters();
            for (int i = 0; i < p.Length; ++i) {
                propertyName.Append(p[i].ParameterType.FullName);
                if (i + 1 < p.Length) {
                    propertyName.Append(',');
                }
            }
            propertyName.Append(')');
            return propertyName.ToString();
        }
        */
        public ReflectionIndexer(PropertyInfo propertyInfo, XmlDocument docs)
        {
            // indexers does have the same name as the object that declare the indexers
            FullyQualifiedName = propertyInfo.DeclaringType.FullName;

            // show the abstract layer that we have getter & setters
            if (propertyInfo.CanRead) {
                getterRegion = new DefaultRegion(0, 0, 0, 0);
            } else {
                getterRegion = null;
            }

            if (propertyInfo.CanWrite) {
                setterRegion = new DefaultRegion(0, 0, 0, 0);
            } else {
                setterRegion = null;
            }

            XmlNode node = null;
            if (docs != null) {
                node = docs.SelectSingleNode ("/Type/Members/Member[@MemberName='" + propertyInfo.Name + "']");
                if (node != null) {
                    XmlNode docNode = node.SelectSingleNode ("Docs/summary");
                    if (docNode != null) {
                        Documentation = node.InnerXml;
                    }
                }
            }

            returnType = new ReflectionReturnType(propertyInfo.PropertyType);

            MethodInfo methodBase = null;
            try {
                methodBase = propertyInfo.GetGetMethod(true);
            } catch (Exception) {}

            if (methodBase == null) {
                try {
                    methodBase = propertyInfo.GetSetMethod(true);
                } catch (Exception) {}
            }

            if (methodBase != null) {
                if (methodBase.IsStatic) {
                    modifiers |= ModifierEnum.Static;
                }

                if (methodBase.IsAssembly) {
                    modifiers |= ModifierEnum.Internal;
                }

                if (methodBase.IsPrivate) { // I assume that private is used most and public last (at least should be)
                    modifiers |= ModifierEnum.Private;
                } else if (methodBase.IsFamily) {
                    modifiers |= ModifierEnum.Protected;
                } else if (methodBase.IsPublic) {
                    modifiers |= ModifierEnum.Public;
                } else if (methodBase.IsFamilyOrAssembly) {
                    modifiers |= ModifierEnum.ProtectedOrInternal;
                } else if (methodBase.IsFamilyAndAssembly) {
                    modifiers |= ModifierEnum.Protected;
                    modifiers |= ModifierEnum.Internal;
                }
            } else { // assume public property, if no methodBase could be get.
                modifiers = ModifierEnum.Public;
            }

            ParameterInfo[] p = propertyInfo.GetIndexParameters();
            foreach (ParameterInfo parameterInfo in p) {
                parameters.Add(new ReflectionParameter(parameterInfo, node));
            }
        }
        public ReflectionProperty(PropertyInfo propertyInfo, XmlDocument docs)
        {
            FullyQualifiedName = String.Concat(propertyInfo.DeclaringType.FullName, ".", propertyInfo.Name);

            // show the abstract layer that we have getter & setters
            if (propertyInfo.CanRead) {
                getterRegion = new DefaultRegion(0, 0, 0, 0);
            } else {
                getterRegion = null;
            }

            if (propertyInfo.CanWrite) {
                setterRegion = new DefaultRegion(0, 0, 0, 0);
            } else {
                setterRegion = null;
            }

            if (docs != null) {
                XmlNode node = docs.SelectSingleNode ("/Type/Members/Member[@MemberName='" + propertyInfo.Name + "']/Docs/summary");
                if (node != null) {
                    Documentation = node.InnerXml;
                }
            }

            returnType = new ReflectionReturnType(propertyInfo.PropertyType);

            MethodInfo methodBase = null;
            try {
                methodBase = propertyInfo.GetGetMethod(true);
            } catch (Exception) {}

            if (methodBase == null) {
                try {
                    methodBase = propertyInfo.GetSetMethod(true);
                } catch (Exception) {}
            }

            if (methodBase != null) {
                if (methodBase.IsStatic) {
                    modifiers |= ModifierEnum.Static;
                }

                if (methodBase.IsAssembly) {
                    modifiers |= ModifierEnum.Internal;
                }

                if (methodBase.IsPrivate) { // I assume that private is used most and public last (at least should be)
                    modifiers |= ModifierEnum.Private;
                } else if (methodBase.IsFamily) {
                    modifiers |= ModifierEnum.Protected;
                } else if (methodBase.IsPublic) {
                    modifiers |= ModifierEnum.Public;
                } else if (methodBase.IsFamilyOrAssembly) {
                    modifiers |= ModifierEnum.ProtectedOrInternal;
                } else if (methodBase.IsFamilyAndAssembly) {
                    modifiers |= ModifierEnum.Protected;
                    modifiers |= ModifierEnum.Internal;
                }

                if (methodBase.IsVirtual) {
                    modifiers |= ModifierEnum.Virtual;
                }
                if (methodBase.IsAbstract) {
                    modifiers |= ModifierEnum.Abstract;
                }

            } else { // assume public property, if no methodBase could be get.
                modifiers = ModifierEnum.Public;
            }
        }
        public SharpAssemblyProperty(SharpAssembly_ asm, Property[] propertyTable, SharpAssemblyClass declaringtype, uint index)
        {
            if (asm == null) {
                throw new System.ArgumentNullException("asm");
            }
            if (propertyTable == null) {
                throw new System.ArgumentNullException("propertyTable");
            }
            if (declaringtype == null) {
                throw new System.ArgumentNullException("declaringType");
            }
            if (index > propertyTable.GetUpperBound(0) || index < 1) {
                throw new System.ArgumentOutOfRangeException("index", index, String.Format("must be between 1 and {0}!", propertyTable.GetUpperBound(0)));
            }

            AssemblyReader assembly = asm.Reader;
            declaringType = declaringtype;

            Property property = asm.Tables.Property[index];
            string name = assembly.GetStringFromHeap(property.Name);
            FullyQualifiedName = String.Concat(declaringType.FullyQualifiedName, ".", name);

            MethodSemantics[] sem = (MethodSemantics[])assembly.MetadataTable.Tables[MethodSemantics.TABLE_ID];
            Method[] method       = (Method[])assembly.MetadataTable.Tables[Method.TABLE_ID];

            uint getterMethodIndex = 0; // used later for parameters

            if (sem == null) goto nosem;

            for (int i = 1; i <= sem.GetUpperBound(0); ++i) {
                uint table = sem[i].Association & 1;
                uint ident = sem[i].Association >> 1;

                if (table == 1 && ident == index) {  // table: Property
                    modifiers = ModifierEnum.None;
                    Method methodDef = method[sem[i].Method];

                    if (methodDef.IsFlagSet(Method.FLAG_STATIC)) {
                        modifiers |= ModifierEnum.Static;
                    }

                    if (methodDef.IsFlagSet(Method.FLAG_ABSTRACT)) {
                        modifiers |= ModifierEnum.Abstract;
                    }

                    if (methodDef.IsFlagSet(Method.FLAG_VIRTUAL)) {
                        modifiers |= ModifierEnum.Virtual;
                    }

                    if (methodDef.IsFlagSet(Method.FLAG_FINAL)) {
                        modifiers |= ModifierEnum.Final;
                    }

                    if (methodDef.IsMaskedFlagSet(Method.FLAG_PRIVATE, Method.FLAG_MEMBERACCESSMASK)) { // I assume that private is used most and public last (at least should be)
                        modifiers |= ModifierEnum.Private;
                    } else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMILY, Method.FLAG_MEMBERACCESSMASK)) {
                        modifiers |= ModifierEnum.Protected;
                    } else if (methodDef.IsMaskedFlagSet(Method.FLAG_PUBLIC, Method.FLAG_MEMBERACCESSMASK)) {
                        modifiers |= ModifierEnum.Public;
                    } else if (methodDef.IsMaskedFlagSet(Method.FLAG_ASSEM, Method.FLAG_MEMBERACCESSMASK)) {
                        modifiers |= ModifierEnum.Internal;
                    } else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMORASSEM, Method.FLAG_MEMBERACCESSMASK)) {
                        modifiers |= ModifierEnum.ProtectedOrInternal;
                    } else if (methodDef.IsMaskedFlagSet(Method.FLAG_FAMANDASSEM, Method.FLAG_MEMBERACCESSMASK)) {
                        modifiers |= ModifierEnum.Protected;
                        modifiers |= ModifierEnum.Internal;
                    }

                    if ((sem[i].Semantics & MethodSemantics.SEM_GETTER) == MethodSemantics.SEM_GETTER) {
                        getterRegion = new DefaultRegion(0, 0, 0, 0);
                        getterMethod = new SharpAssemblyMethod(asm, method, declaringtype, sem[i].Method);
                        getterMethodIndex = sem[i].Method;
                    }

                    if ((sem[i].Semantics & MethodSemantics.SEM_SETTER) == MethodSemantics.SEM_SETTER) {
                        setterRegion = new DefaultRegion(0, 0, 0, 0);
                        setterMethod = new SharpAssemblyMethod(asm, method, declaringtype, sem[i].Method);
                    }
                }

            }

            nosem:

            // Attributes
            ArrayList attrib = asm.Attributes.Property[index] as ArrayList;
            if (attrib == null) goto noatt;

            AbstractAttributeSection sect = new AbstractAttributeSection();

            foreach(SharpCustomAttribute customattribute in attrib) {
                sect.Attributes.Add(new SharpAssemblyAttribute(asm, customattribute));
            }

            attributes.Add(sect);

            noatt:

            if ((property.Flags & Property.FLAG_SPECIALNAME) == Property.FLAG_SPECIALNAME) modifiers |= ModifierEnum.SpecialName;

            uint offset = property.Type;
            assembly.LoadBlob(ref offset);
            offset += 1; // skip calling convention
            int paramCount = assembly.LoadBlob(ref offset);

            returnType = new SharpAssemblyReturnType(asm, ref offset);

            IReturnType[] returnTypes = new IReturnType[paramCount];
            for (int i = 0; i < returnTypes.Length; ++i) {
                returnTypes[i] = new SharpAssemblyReturnType(asm, ref offset);
            }

            if (getterMethodIndex != 0) {
                AddParameters(asm, asm.Tables.Method, getterMethodIndex, returnTypes);
            } else {
                AddParameters(asm, returnTypes);
            }
        }