GetTypeParameterDescription() public static method

public static GetTypeParameterDescription ( ITypeParameterSymbol symbol, MetadataItem item, ITripleSlashCommentParserContext context ) : ApiParameter
symbol ITypeParameterSymbol
item MetadataItem
context ITripleSlashCommentParserContext
return Microsoft.DocAsCode.DataContracts.ManagedReference.ApiParameter
Example #1
0
        public override MetadataItem VisitMethod(IMethodSymbol symbol)
        {
            MetadataItem result = GetYamlItem(symbol);

            if (result == null)
            {
                return(null);
            }
            if (result.Syntax == null)
            {
                result.Syntax = new SyntaxDetail {
                    Content = new SortedList <SyntaxLanguage, string>()
                };
            }

            if (symbol.TypeParameters.Length > 0)
            {
                if (result.Syntax.TypeParameters == null)
                {
                    result.Syntax.TypeParameters = new List <ApiParameter>();
                }

                foreach (var p in symbol.TypeParameters)
                {
                    var param = VisitorHelper.GetTypeParameterDescription(p, result, GetTripleSlashCommentParserContext(result, _preserveRawInlineComments));
                    result.Syntax.TypeParameters.Add(param);
                }
            }

            var typeGenericParameters = symbol.ContainingType.IsGenericType ? symbol.ContainingType.Accept(TypeGenericParameterNameVisitor.Instance) : EmptyListOfString;

            var methodGenericParameters = symbol.IsGenericMethod ? (from p in symbol.TypeParameters select p.Name).ToList() : EmptyListOfString;

            AddMethodSyntax(symbol, result, typeGenericParameters, methodGenericParameters);

            if (result.Syntax.Content == null)
            {
                result.Syntax.Content = new SortedList <SyntaxLanguage, string>();
            }
            _generator.GenerateSyntax(result.Type, symbol, result.Syntax, this);

            _generator.GenerateMethod(symbol, result, this);

            if (symbol.IsOverride && symbol.OverriddenMethod != null)
            {
                result.Overridden = AddSpecReference(symbol.OverriddenMethod, typeGenericParameters, methodGenericParameters);
            }

            result.Overload = AddOverloadReference(symbol.OriginalDefinition);

            AddMemberImplements(symbol, result, typeGenericParameters, methodGenericParameters);

            result.Attributes = GetAttributeInfo(symbol.GetAttributes());

            result.IsExplicitInterfaceImplementation = !symbol.ExplicitInterfaceImplementations.IsEmpty;
            result.IsExtensionMethod = symbol.IsExtensionMethod;

            return(result);
        }
Example #2
0
        public override MetadataItem VisitNamedType(INamedTypeSymbol symbol)
        {
            var item = DefaultVisit(symbol);

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

            GenerateInheritance(symbol, item);

            item.Type = VisitorHelper.GetMemberTypeFromTypeKind(symbol.TypeKind);
            if (item.Syntax == null)
            {
                item.Syntax = new SyntaxDetail {
                    Content = new SortedList <SyntaxLanguage, string>()
                };
            }
            if (item.Syntax.Content == null)
            {
                item.Syntax.Content = new SortedList <SyntaxLanguage, string>();
            }
            _generator.GenerateSyntax(item.Type, symbol, item.Syntax, this);

            if (symbol.TypeParameters.Length > 0)
            {
                if (item.Syntax.TypeParameters == null)
                {
                    item.Syntax.TypeParameters = new List <ApiParameter>();
                }

                foreach (var p in symbol.TypeParameters)
                {
                    var param = VisitorHelper.GetTypeParameterDescription(p, item, GetTripleSlashCommentParserContext(item, _preserveRawInlineComments));
                    item.Syntax.TypeParameters.Add(param);
                }
            }

            if (symbol.TypeKind == TypeKind.Delegate)
            {
                var typeGenericParameters = symbol.IsGenericType ? symbol.Accept(TypeGenericParameterNameVisitor.Instance) : EmptyListOfString;
                AddMethodSyntax(symbol.DelegateInvokeMethod, item, typeGenericParameters, EmptyListOfString);
            }

            _generator.GenerateNamedType(symbol, item, this);

            item.Items = new List <MetadataItem>();
            foreach (var member in symbol.GetMembers().Where(s => !(s is INamedTypeSymbol)))
            {
                var memberItem = member.Accept(this);
                if (memberItem != null)
                {
                    item.Items.Add(memberItem);
                }
            }

            AddReference(symbol);

            item.Attributes = GetAttributeInfo(symbol.GetAttributes());

            return(item);
        }