private static string GetEiiContainerTypeName(IPropertySymbol symbol)
 {
     if (symbol.ExplicitInterfaceImplementations.Length == 0)
     {
         return(null);
     }
     for (int i = 0; i < symbol.ExplicitInterfaceImplementations.Length; i++)
     {
         if (VisitorHelper.CanVisit(symbol.ExplicitInterfaceImplementations[i]))
         {
             return(symbol.ExplicitInterfaceImplementations[i].ContainingType.ToDisplayString(EiiContainerTypeFormat));
         }
     }
     Debug.Fail("Should not be here!");
     return(null);
 }
        private static string GetMemberName(IPropertySymbol symbol)
        {
            string name = symbol.Name;

            if (symbol.ExplicitInterfaceImplementations.Length == 0)
            {
                return(symbol.Name);
            }
            for (int i = 0; i < symbol.ExplicitInterfaceImplementations.Length; i++)
            {
                if (VisitorHelper.CanVisit(symbol.ExplicitInterfaceImplementations[i]))
                {
                    return(symbol.ExplicitInterfaceImplementations[i].ToDisplayString(EiiMethodFormat));
                }
            }
            Debug.Fail("Should not be here!");
            return(symbol.Name);
        }
Beispiel #3
0
        public override MetadataItem DefaultVisit(ISymbol symbol)
        {
            if (!VisitorHelper.CanVisit(symbol))
            {
                return(null);
            }
            var item = new MetadataItem
            {
                Name       = VisitorHelper.GetId(symbol),
                RawComment = symbol.GetDocumentationCommentXml(),
                Language   = this.language,
            };

            item.Source = VisitorHelper.GetSourceDetail(symbol);
            VisitorHelper.FeedComments(item);

            return(item);
        }
        public override MetadataItem VisitMethod(IMethodSymbol symbol)
        {
            var item = this.AddYamlItem(symbol);

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

            if (item.Syntax == null)
            {
                item.Syntax = new SyntaxDetail {
                    Content = new Dictionary <SyntaxLanguage, string>()
                };
            }

            if (!symbol.ReturnsVoid)
            {
                item.Syntax.Return = VisitorHelper.GetParameterDescription(symbol.ReturnType, item, true, ShortDisplayFormat);
            }

            if (item.Syntax.Parameters == null)
            {
                item.Syntax.Parameters = new List <ApiParameter>();
            }

            foreach (var i in symbol.Parameters)
            {
                var param = VisitorHelper.GetParameterDescription(i, item, false, ShortDisplayFormat);
                Debug.Assert(param.Type != null);

                item.Syntax.Parameters.Add(param);
            }

            return(item);
        }
        public override MetadataItem VisitNamedType(INamedTypeSymbol symbol)
        {
            var item = this.DefaultVisit(symbol);

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

            var syntaxRef = symbol.DeclaringSyntaxReferences.FirstOrDefault();

            Debug.Assert(syntaxRef != null);
            if (syntaxRef == null)
            {
                return(null);
            }
            var syntaxNode = syntaxRef.GetSyntax();

            Debug.Assert(syntaxNode != null);
            if (syntaxNode == null)
            {
                return(null);
            }

            var type = symbol.BaseType;

            if (type != null)
            {
                item.Inheritance = new List <SourceDetail>();
                while (type != null)
                {
                    SourceDetail link = VisitorHelper.GetLinkDetail(type, ShortDisplayFormat);

                    item.Inheritance.Add(link);
                    type = type.BaseType;
                }

                item.Inheritance.Reverse();
            }
            Debug.Assert(this.parent != null && this.currentNamespace != null);
            if (this.currentNamespace != null)
            {
                if (this.currentNamespace.Items == null)
                {
                    this.currentNamespace.Items = new List <MetadataItem>();
                }

                this.currentNamespace.Items.Add(item);
            }

            item.Type = VisitorHelper.GetMemberTypeFromTypeKind(symbol.TypeKind);
            string syntaxStr = this.GetSyntaxContent(item.Type, symbol, syntaxNode);

            Debug.Assert(!string.IsNullOrEmpty(syntaxStr));
            if (string.IsNullOrEmpty(syntaxStr))
            {
                return(null);
            }

            if (item.Syntax == null)
            {
                item.Syntax = new SyntaxDetail {
                    Content = new Dictionary <SyntaxLanguage, string>()
                };
            }

            if (item.Syntax.Content == null)
            {
                item.Syntax.Content = new Dictionary <SyntaxLanguage, string>();
            }

            item.Syntax.Content.Add(this.language, syntaxStr);

            var parentSaved = this.parent;

            this.parent = item;

            foreach (var member in symbol.GetMembers())
            {
                var nsItem = member.Accept(this);
            }

            this.parent = parentSaved;
            return(item);
        }