Example #1
0
        public static IEnumerable <TypeReference> GetUserImplementedInterfaces(TypeDefinition type)
        {
            HashSet <string>     inheritedInterfaces = GetInheritedInterfaces(type);
            List <TypeReference> userInterfaces      = new List <TypeReference> ();

            foreach (var ii in type.Interfaces)
            {
                var           iface  = ii.InterfaceType;
                TypeReference lookup = iface.Resolve() ?? iface;
                if (!inheritedInterfaces.Contains(GetQualifiedTypeName(lookup)))
                {
                    userInterfaces.Add(iface);
                }
            }
            return(userInterfaces.Where(i => MDocUpdater.IsPublic(i.Resolve())));
        }
        protected override string GetTypeDeclaration(TypeDefinition type)
        {
            string visibility = GetTypeVisibility(type.Attributes);

            if (visibility == null)
            {
                return(null);
            }

            StringBuilder buf = new StringBuilder();

            buf.Append(".class ");
            if (type.IsNested)
            {
                buf.Append("nested ");
            }
            buf.Append(visibility).Append(" ");
            if (type.IsInterface)
            {
                buf.Append("interface ");
            }
            if (type.IsSequentialLayout)
            {
                buf.Append("sequential ");
            }
            if (type.IsAutoLayout)
            {
                buf.Append("auto ");
            }
            if (type.IsAnsiClass)
            {
                buf.Append("ansi ");
            }
            if (type.IsAbstract)
            {
                buf.Append("abstract ");
            }
            if (type.IsSerializable)
            {
                buf.Append("serializable ");
            }
            if (type.IsSealed)
            {
                buf.Append("sealed ");
            }
            if (type.IsBeforeFieldInit)
            {
                buf.Append("beforefieldinit ");
            }
            var state = MemberFormatterState;

            MemberFormatterState = MemberFormatterState.WithinGenericTypeParameters;
            buf.Append(GetName(type));
            MemberFormatterState = state;
            var full = new ILFullMemberFormatter(this.TypeMap);

            if (type.BaseType != null)
            {
                buf.Append(" extends ");
                if (type.BaseType.FullName == "System.Object")
                {
                    buf.Append("System.Object");
                }
                else
                {
                    buf.Append(full.GetName(type.BaseType).Substring("class ".Length));
                }
            }
            bool first = true;

            foreach (var name in type.Interfaces.Where(i => MDocUpdater.IsPublic(i.InterfaceType.Resolve()))
                     .Select(i => full.GetName(i.InterfaceType))
                     .OrderBy(n => n))
            {
                if (first)
                {
                    buf.Append(" implements ");
                    first = false;
                }
                else
                {
                    buf.Append(", ");
                }
                buf.Append(name);
            }

            return(buf.ToString());
        }