예제 #1
0
        private static async Task Overloads(StreamWriter writer, IEnumerable <MethodBase> methods, XDocument xmlComments)
        {
            await writer.WriteLineAsync("## Overloads");

            await writer.WriteLineAsync("| | |");

            await writer.WriteLineAsync("|_|_|");

            foreach (var method in methods)
            {
                await writer.WriteAsync("[");

                await writer.WriteAsync(method.Name);

                if (method.IsGenericMethodDefinition)
                {
                    var genericArguments = method.GetGenericArguments();

                    await writer.WriteAsync("&lt;");

                    await TypeHelper.FullName(writer, genericArguments[0], t => t.Name, "&lt;", "&gt;");

                    for (var i = 1; i < genericArguments.Length; ++i)
                    {
                        await writer.WriteAsync(",");

                        await TypeHelper.FullName(writer, genericArguments[i], t => t.Name, "&lt;", "&gt;");
                    }

                    await writer.WriteAsync("&gt;");
                }

                await writer.WriteAsync("(");

                var parameters = method.GetParameters();

                if (parameters.Length > 0)
                {
                    await TypeHelper.FullName(writer, parameters[0].ParameterType, t => t.Name, "&lt;", "&gt;");

                    for (var i = 1; i < parameters.Length; i++)
                    {
                        await writer.WriteAsync(", ");

                        await TypeHelper.FullName(writer, parameters[i].ParameterType, t => t.Name, "&lt;", "&gt;");
                    }
                }

                await writer.WriteAsync(")](");

                /*await writer.WriteAsync(FileNameHelper.MethodFileName(string.Empty, method));*/
                await writer.WriteAsync(")|");

                var summary = XmlCommentHelper.Summary(XmlCommentHelper.MethodElement(xmlComments, method));

                await writer.WriteLineAsync(summary);
            }

            await writer.WriteLineAsync();
        }
예제 #2
0
        private static async Task MethodDetails(
            StreamWriter writer,
            Assembly assembly,
            Type type,
            MethodInfo method,
            XDocument xmlComments)
        {
            await writer.WriteLineAsync(XmlCommentHelper.Summary(XmlCommentHelper.MethodElement(xmlComments, method)));

            await writer.WriteLineAsync();

            await MethodDocument.Signature(writer, type, method);

            await MethodDocument.TypeParameters(writer, method, xmlComments);

            await MethodDocument.Parameters(writer, method, xmlComments);

            await MethodDocument.Returns(writer, method, xmlComments);

            /* await MethodDocument.Implements(); */
            await MethodDocument.Exceptions(writer, assembly, method, xmlComments);

            /* await MethodDocument.Examples() */
            /* await MethodDocument.Remarks() */
        }
예제 #3
0
        private static async Task Exceptions(
            StreamWriter writer,
            Assembly assembly,
            MethodInfo method,
            XDocument xmlComments)
        {
            var exceptions = XmlCommentHelper.MethodElement(xmlComments, method)?.Descendants("exception").ToList();

            if (exceptions != null && exceptions.Count > 0)
            {
                await writer.WriteLineAsync("### Exceptions");

                foreach (var exception in exceptions)
                {
                    var exceptionTypeName = exception.Attributes("cref").FirstOrDefault()?.Value;

                    if (exceptionTypeName != null)
                    {
                        var exceptionType = TypeHelper.GetType(
                            assembly,
                            exceptionTypeName.Substring(exceptionTypeName.IndexOf(':', StringComparison.Ordinal) + 1));

                        if (exceptionType != null)
                        {
                            await TypeHelper.FullName(writer, exceptionType, t => t.Name, "&lt;", "&gt;");
                        }
                        else
                        {
                            var start = exceptionTypeName.LastIndexOf('.');

                            if (start >= 0)
                            {
                                exceptionTypeName = exceptionTypeName.Substring(start + 1);
                            }

                            var end = exceptionTypeName.IndexOf('`', StringComparison.Ordinal);

                            if (end >= 0)
                            {
                                exceptionTypeName = exceptionTypeName.Substring(0, end);
                            }

                            await writer.WriteAsync(exceptionTypeName);
                        }

                        await writer.WriteLineAsync("  ");

                        await XmlCommentHelper.WriteValue(writer, exception);

                        await writer.WriteLineAsync();

                        await writer.WriteLineAsync();
                    }
                }
            }
        }
        private static async Task Constructors(StreamWriter writer, Type type, XDocument xmlComments)
        {
            var constructors = type.GetConstructors();

            if (constructors.Length > 0)
            {
                await writer.WriteLineAsync("### Constructors");

                await writer.WriteLineAsync("| | |");

                await writer.WriteLineAsync("|_|_|");

                foreach (var constructor in constructors)
                {
                    await writer.WriteAsync("[");

                    await TypeHelper.FullName(writer, type, t => t.Name, "&lt;", "&gt;");

                    await writer.WriteAsync("(");

                    var parameters = constructor.GetParameters();

                    if (parameters.Length > 0)
                    {
                        await TypeHelper.FullName(writer, parameters[0].ParameterType, t => t.Name, "&lt;", "&gt;");

                        for (var i = 1; i < parameters.Length; i++)
                        {
                            await writer.WriteAsync(", ");

                            await TypeHelper.FullName(writer, parameters[i].ParameterType, t => t.Name, "&lt;", "&gt;");
                        }
                    }

                    await writer.WriteAsync(")](");

                    await writer.WriteAsync(FileNameHelper.ConstructorFileName(string.Empty, type));

                    await writer.WriteAsync(")|");

                    await writer.WriteLineAsync(
                        XmlCommentHelper.Summary(XmlCommentHelper.MethodElement(xmlComments, constructor)));
                }
            }
        }
        private static async Task Methods(StreamWriter writer, Type type, XDocument xmlComments)
        {
            var methods = type.GetMethods().Where(o => !o.IsSpecialName).Where(TypeHelper.IgnoreDeclaringType).ToList();

            if (methods.Count > 0)
            {
                await writer.WriteLineAsync("### Methods");

                await writer.WriteLineAsync("| | |");

                await writer.WriteLineAsync("|_|_|");

                foreach (var method in methods)
                {
                    await writer.WriteAsync("[");

                    await writer.WriteAsync(method.Name);

                    if (method.IsGenericMethodDefinition)
                    {
                        var genericArguments = method.GetGenericArguments();

                        await writer.WriteAsync("&lt;");

                        await TypeHelper.FullName(writer, genericArguments[0], t => t.Name, "&lt;", "&gt;");

                        for (var i = 1; i < genericArguments.Length; ++i)
                        {
                            await writer.WriteAsync(",");

                            await TypeHelper.FullName(writer, genericArguments[i], t => t.Name, "&lt;", "&gt;");
                        }

                        await writer.WriteAsync("&gt;");
                    }

                    await writer.WriteAsync("(");

                    var parameters = method.GetParameters();

                    if (parameters.Length > 0)
                    {
                        await TypeHelper.FullName(writer, parameters[0].ParameterType, t => t.Name, "&lt;", "&gt;");

                        for (var i = 1; i < parameters.Length; i++)
                        {
                            await writer.WriteAsync(", ");

                            await TypeHelper.FullName(writer, parameters[i].ParameterType, t => t.Name, "&lt;", "&gt;");
                        }
                    }

                    await writer.WriteAsync(")](");

                    await writer.WriteAsync(FileNameHelper.MethodFileName(string.Empty, method));

                    await writer.WriteAsync(")|");

                    var summary = XmlCommentHelper.Summary(XmlCommentHelper.MethodElement(xmlComments, method));

                    await writer.WriteAsync(summary);

                    if (method.DeclaringType != type)
                    {
                        if (summary.Length > 0)
                        {
                            await writer.WriteAsync("<br/>");
                        }

                        await writer.WriteAsync("(Inherited from ");

                        await writer.WriteAsync(method.DeclaringType?.Name);

                        await writer.WriteAsync(")");
                    }

                    await writer.WriteLineAsync();
                }
            }
        }