Esempio n. 1
0
        public void HandleType(Type currentType, XmlDoc xdoc)
        {
            if (!(currentType.IsNested ? currentType.IsNestedPublic :
                  currentType.IsPublic))
            {
                return;
            }
            var typeFullName = currentType.FullName;

            if (!this.docs.ContainsKey(typeFullName))
            {
                var docVisitor = new TypeLinkAndBuilder(currentType);
                this.docs[typeFullName] = docVisitor;
            }
            var summary = GetSummary(
                currentType,
                xdoc,
                TypeNameUtil.XmlDocMemberName(currentType));

            if (summary == null)
            {
                Console.WriteLine("no summary for " + typeFullName);
            }
            else
            {
                this.docs[typeFullName].Builder.Append(summary)
                .Append("\r\n");
            }
        }
Esempio n. 2
0
        public void HandleMember(object info, XmlDoc xmldoc)
        {
            var isPublicOrProtected = false;
            var typeInfo            = info as Type;
            var methodInfo          = info as MethodInfo;
            var propertyInfo        = info as PropertyInfo;
            var fieldInfo           = info as FieldInfo;

            if (methodInfo != null)
            {
                isPublicOrProtected = methodInfo.IsPublic || methodInfo.IsFamily;
            }
            if (propertyInfo != null)
            {
                isPublicOrProtected = (propertyInfo.CanRead &&
                                       (propertyInfo.GetGetMethod().IsPublic ||
                                        propertyInfo.GetGetMethod().IsFamily)) ||
                                      (propertyInfo.CanWrite &&
                                       (propertyInfo.GetSetMethod().IsPublic ||
                                        propertyInfo.GetSetMethod().IsFamily));
            }
            if (fieldInfo != null)
            {
                isPublicOrProtected = fieldInfo.IsPublic || fieldInfo.IsFamily;
            }
            if (!isPublicOrProtected)
            {
                return;
            }
            string memberAnchor = MemberAnchor(info);

            this.memberFormats[memberAnchor] = FormatMember(info);
            if (!this.docs.ContainsKey(memberAnchor))
            {
                var docVisitor = new StringBuilder();
                this.docs[memberAnchor] = docVisitor;
            }
            string memberFullName = TypeNameUtil.XmlDocMemberName(info);
            var    summary        = SummaryVisitor.GetSummary(
                info as MemberInfo,
                xmldoc,
                memberFullName);

            if (summary == null)
            {
                Console.WriteLine("no summary for " + memberFullName);
            }
            else
            {
                this.docs[memberAnchor].Append(summary)
                .Append("\r\n");
            }
        }
Esempio n. 3
0
        public void HandleMember(MemberInfo info, XmlDoc xmldoc)
        {
            var signature = String.Empty;
            var mnu       = TypeNameUtil.XmlDocMemberName(info);
            var mnm       = xmldoc.GetMemberNode(mnu);

            if (info is MethodBase)
            {
                var method = (MethodBase)info;
                if (!method.IsPublic && !method.IsFamily)
                {
                    // Ignore methods other than public and protected
                    // methods
                    return;
                }
                if (mnm == null)
                {
                    Console.WriteLine("member info not found: " + mnu);
                    return;
                }
                using (var ch = this.AddMember(info)) {
                    signature = FormatMethod(method, false);
                    this.WriteLine("<a id=\"" +
                                   MemberSummaryVisitor.MemberAnchor(info) + "\"></a>");
                    this.WriteLine("### " + Heading(info) +
                                   "\r\n\r\n" + signature + "\r\n\r\n");
                    var attr = method.GetCustomAttribute(typeof(ObsoleteAttribute)) as
                               ObsoleteAttribute;
                    if (attr != null)
                    {
                        this.WriteLine("<b>Deprecated.</b> " +
                                       DocGenUtil.HtmlEscape(attr.Message) + "\r\n\r\n");
                    }
                    var cattr =
                        method.GetCustomAttribute(typeof(CLSCompliantAttribute)) as
                        CLSCompliantAttribute;
                    if (cattr != null && !cattr.IsCompliant)
                    {
                        this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n");
                    }
                    this.paramStr.Clear();
                    this.returnStr.Clear();
                    this.exceptionStr.Clear();
                    XmlDoc.VisitInnerNode(mnm, this);
                    if (this.paramStr.Length > 0)
                    {
                        this.Write("<b>Parameters:</b>\r\n\r\n");
                        var paramString = this.paramStr.ToString();
                        // Decrease spacing between list items
                        paramString = paramString.Replace("\r\n * ", " * ");
                        this.Write(paramString);
                    }
                    this.Write(this.returnStr.ToString());
                    if (this.exceptionStr.Length > 0)
                    {
                        this.Write("<b>Exceptions:</b>\r\n\r\n");
                        this.Write(this.exceptionStr.ToString());
                    }
                }
            }
            else if (info is Type)
            {
                var type = (Type)info;
                if (!(type.IsNested ? type.IsNestedPublic : type.IsPublic))
                {
                    // Ignore nonpublic types
                    return;
                }
                if (mnm == null)
                {
                    Console.WriteLine("member info not found: " + mnu);
                    return;
                }
                using (var ch = this.AddMember(info)) {
                    this.WriteLine("## " + Heading(type) + "\r\n\r\n");
                    this.WriteLine(FormatTypeSig(type) + "\r\n\r\n");
                    var attr = type.GetCustomAttribute(typeof(ObsoleteAttribute)) as
                               ObsoleteAttribute;
                    if (attr != null)
                    {
                        this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n");
                    }
                    var cattr = type.GetCustomAttribute(typeof(CLSCompliantAttribute)) as
                                CLSCompliantAttribute;
                    if (cattr != null && !cattr.IsCompliant)
                    {
                        this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n");
                    }
                    this.paramStr.Clear();
                    XmlDoc.VisitInnerNode(mnm, this);
                    this.Write("\r\n\r\n");
                    this.WriteLine("<<<MEMBER_SUMMARY>>>");
                    if (this.paramStr.Length > 0)
                    {
                        this.Write("<b>Parameters:</b>\r\n\r\n");
                        var paramString = this.paramStr.ToString();
                        // Decrease spacing between list items
                        paramString = paramString.Replace("\r\n * ", " * ");
                        this.Write(paramString);
                    }
                }
            }
            else if (info is PropertyInfo)
            {
                var property = (PropertyInfo)info;
                if (!PropertyIsPublicOrFamily(property))
                {
                    // Ignore methods other than public and protected
                    // methods
                    return;
                }
                if (mnm == null)
                {
                    Console.WriteLine("member info not found: " + mnu);
                    return;
                }
                using (var ch = this.AddMember(info)) {
                    signature = FormatProperty(property);
                    this.WriteLine("<a id=\"" +
                                   MemberSummaryVisitor.MemberAnchor(info) + "\"></a>");
                    this.WriteLine("### " + property.Name + "\r\n\r\n" + signature +
                                   "\r\n\r\n");
                    var attr = property.GetCustomAttribute(typeof(ObsoleteAttribute)) as
                               ObsoleteAttribute;
                    if (attr != null)
                    {
                        this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n");
                    }
                    var cattr =
                        property.GetCustomAttribute(typeof(CLSCompliantAttribute)) as
                        CLSCompliantAttribute;
                    if (cattr != null && !cattr.IsCompliant)
                    {
                        this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n");
                    }
                    this.paramStr.Clear();
                    this.returnStr.Clear();
                    this.exceptionStr.Clear();
                    XmlDoc.VisitInnerNode(mnm, this);
                    if (this.paramStr.Length > 0)
                    {
                        this.Write("<b>Parameters:</b>\r\n\r\n");
                        this.Write(this.paramStr.ToString());
                    }
                    this.Write(this.returnStr.ToString());
                    if (this.exceptionStr.Length > 0)
                    {
                        this.Write("<b>Exceptions:</b>\r\n\r\n");
                        this.Write(this.exceptionStr.ToString());
                    }
                }
            }
            else if (info is FieldInfo)
            {
                var field = (FieldInfo)info;
                if (!field.IsPublic && !field.IsFamily)
                {
                    // Ignore nonpublic, nonprotected fields
                    return;
                }
                if (mnm == null)
                {
                    Console.WriteLine("member info not found: " + mnu);
                    return;
                }
                using (var ch = this.AddMember(info)) {
                    signature = FormatField(field);
                    this.WriteLine("<a id=\"" +
                                   MemberSummaryVisitor.MemberAnchor(info) + "\"></a>");
                    this.WriteLine("### " + field.Name + "\r\n\r\n" + signature +
                                   "\r\n\r\n");
                    var attr = field.GetCustomAttribute(typeof(ObsoleteAttribute)) as
                               ObsoleteAttribute;
                    if (attr != null)
                    {
                        this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n");
                    }
                    var cattr = field.GetCustomAttribute(typeof(CLSCompliantAttribute)) as
                                CLSCompliantAttribute;
                    if (cattr != null && !cattr.IsCompliant)
                    {
                        this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n");
                    }
                    XmlDoc.VisitInnerNode(mnm, this);
                }
            }
        }