GetCommentId() 공개 정적인 메소드

public static GetCommentId ( ISymbol symbol ) : string
symbol ISymbol
리턴 string
예제 #1
0
        public override MetadataItem DefaultVisit(ISymbol symbol)
        {
            if (!FilterVisitor.CanVisitApi(symbol))
            {
                return(null);
            }
            var item = new MetadataItem
            {
                Name       = VisitorHelper.GetId(symbol),
                CommentId  = VisitorHelper.GetCommentId(symbol),
                RawComment = symbol.GetDocumentationCommentXml(),
                Language   = Language,
            };

            item.DisplayNames          = new SortedList <SyntaxLanguage, string>();
            item.DisplayNamesWithType  = new SortedList <SyntaxLanguage, string>();
            item.DisplayQualifiedNames = new SortedList <SyntaxLanguage, string>();
            item.Source = VisitorHelper.GetSourceDetail(symbol);
            var assemblyName = symbol.ContainingAssembly?.Name;

            item.AssemblyNameList = string.IsNullOrEmpty(assemblyName) ? null : new List <string> {
                assemblyName
            };
            if (!(symbol is INamespaceSymbol))
            {
                var namespaceName = VisitorHelper.GetId(symbol.ContainingNamespace);
                item.NamespaceName = string.IsNullOrEmpty(namespaceName) ? null : namespaceName;
            }

            VisitorHelper.FeedComments(item, GetTripleSlashCommentParserContext(item, _preserveRawInlineComments));
            if (item.Exceptions != null)
            {
                foreach (var exceptions in item.Exceptions)
                {
                    AddReference(exceptions.Type, exceptions.CommentId);
                }
            }

            if (item.Sees != null)
            {
                foreach (var i in item.Sees.Where(l => l.LinkType == LinkType.CRef))
                {
                    AddReference(i.LinkId, i.CommentId);
                }
            }

            if (item.SeeAlsos != null)
            {
                foreach (var i in item.SeeAlsos.Where(l => l.LinkType == LinkType.CRef))
                {
                    AddReference(i.LinkId, i.CommentId);
                }
            }

            _generator.DefaultVisit(symbol, item, this);
            return(item);
        }
예제 #2
0
 public string AddSpecReference(
     ISymbol symbol,
     IReadOnlyList <string> typeGenericParameters   = null,
     IReadOnlyList <string> methodGenericParameters = null)
 {
     try
     {
         return(_generator.AddSpecReference(symbol, typeGenericParameters, methodGenericParameters, _references, this));
     }
     catch (Exception ex)
     {
         throw new DocfxException($"Unable to generate spec reference for {VisitorHelper.GetCommentId(symbol)}", ex);
     }
 }
예제 #3
0
        internal string AddSpecReference(
            ISymbol symbol,
            IReadOnlyList <string> typeGenericParameters,
            IReadOnlyList <string> methodGenericParameters,
            Dictionary <string, ReferenceItem> references,
            SymbolVisitorAdapter adapter)
        {
            var rawId = VisitorHelper.GetId(symbol);
            var id    = SpecIdHelper.GetSpecId(symbol, typeGenericParameters, methodGenericParameters);

            if (string.IsNullOrEmpty(id))
            {
                throw new InvalidDataException($"Fail to parse id for symbol {symbol.MetadataName} in namespace {symbol.ContainingSymbol?.MetadataName}.");
            }
            ReferenceItem reference = new ReferenceItem()
            {
                Parts = new SortedList <SyntaxLanguage, List <LinkItem> >()
            };

            GenerateReferenceInternal(symbol, reference, adapter);
            var originalSymbol = symbol;
            var reducedFrom    = (symbol as IMethodSymbol)?.ReducedFrom;

            if (reducedFrom != null)
            {
                originalSymbol = reducedFrom;
            }
            reference.IsDefinition = (originalSymbol == symbol) && (id == rawId) && (symbol.IsDefinition || VisitorHelper.GetId(symbol.OriginalDefinition) == rawId);

            if (!reference.IsDefinition.Value && rawId != null)
            {
                reference.Definition = AddReference(originalSymbol.OriginalDefinition, references, adapter);
            }

            reference.Parent    = GetReferenceParent(originalSymbol, typeGenericParameters, methodGenericParameters, references, adapter);
            reference.CommentId = VisitorHelper.GetCommentId(originalSymbol);

            if (!references.ContainsKey(id))
            {
                references[id] = reference;
            }
            else
            {
                references[id].Merge(reference);
            }

            return(id);
        }
예제 #4
0
        internal string AddSpecReference(
            ISymbol symbol,
            IReadOnlyList <string> typeGenericParameters,
            IReadOnlyList <string> methodGenericParameters,
            Dictionary <string, ReferenceItem> references,
            SymbolVisitorAdapter adapter)
        {
            var           rawId     = VisitorHelper.GetId(symbol);
            var           id        = SpecIdHelper.GetSpecId(symbol, typeGenericParameters, methodGenericParameters);
            ReferenceItem reference = new ReferenceItem();

            reference.Parts = new SortedList <SyntaxLanguage, List <LinkItem> >();
            GenerateReferenceInternal(symbol, reference, adapter);
            var originalSymbol = symbol;
            var reducedFrom    = (symbol as IMethodSymbol)?.ReducedFrom;

            if (reducedFrom != null)
            {
                originalSymbol = reducedFrom;
            }
            reference.IsDefinition = (originalSymbol == symbol) && (id == rawId) && symbol.IsDefinition;

            if (!reference.IsDefinition.Value && rawId != null)
            {
                reference.Definition = AddReference(originalSymbol.OriginalDefinition, references, adapter);
            }

            reference.Parent    = GetReferenceParent(originalSymbol, typeGenericParameters, methodGenericParameters, references, adapter);
            reference.CommentId = VisitorHelper.GetCommentId(originalSymbol);

            if (!references.ContainsKey(id))
            {
                references[id] = reference;
            }
            else
            {
                references[id].Merge(reference);
            }

            return(id);
        }
예제 #5
0
        internal string AddReference(ISymbol symbol, Dictionary <string, ReferenceItem> references, SymbolVisitorAdapter adapter)
        {
            var id = VisitorHelper.GetId(symbol);

            ReferenceItem reference = new ReferenceItem();

            reference.Parts        = new SortedList <SyntaxLanguage, List <LinkItem> >();
            reference.IsDefinition = symbol.IsDefinition;
            reference.CommentId    = VisitorHelper.GetCommentId(symbol);
            GenerateReferenceInternal(symbol, reference, adapter);

            if (!references.ContainsKey(id))
            {
                references[id] = reference;
            }
            else
            {
                references[id].Merge(reference);
            }

            return(id);
        }
 /// <summary>
 /// return a symbol in the assigned container
 /// </summary>
 /// <param name="container">container</param>
 /// <param name="symbol">symbol</param>
 /// <returns>related symbol in the compilation</returns>
 public static ISymbol FindSymbol(this INamespaceOrTypeSymbol container, ISymbol symbol)
 {
     return(FindCore(container, GetQualifiedNameList(symbol)).Where(m => VisitorHelper.GetCommentId(m) == VisitorHelper.GetCommentId(symbol)).FirstOrDefault());
 }