GetSpecId() public static method

public static GetSpecId ( ISymbol symbol, IReadOnlyList typeGenericParameters, IReadOnlyList methodGenericParameters = null ) : string
symbol ISymbol
typeGenericParameters IReadOnlyList
methodGenericParameters IReadOnlyList
return string
Exemplo n.º 1
0
        internal string AddSpecReference(
            ISymbol symbol,
            IReadOnlyList <string> typeGenericParameters,
            IReadOnlyList <string> methodGenericParameters,
            Dictionary <string, ReferenceItem> references,
            SymbolVisitorAdapter adapter)
        {
            var           id        = SpecIdHelper.GetSpecId(symbol, typeGenericParameters, methodGenericParameters);
            ReferenceItem reference = new ReferenceItem();

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

            if (!symbol.IsDefinition)
            {
                var def            = symbol.OriginalDefinition;
                var typeParameters = def.Accept(TypeGenericParameterNameVisitor.Instance);
                reference.Definition = AddSpecReference(def, typeParameters, null, references, adapter);
            }

            reference.Parent = GetReferenceParent(symbol, typeGenericParameters, methodGenericParameters, references, adapter);

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

            return(id);
        }
Exemplo n.º 2
0
 private void AddInheritedMembers(INamedTypeSymbol symbol, INamedTypeSymbol type, Dictionary <string, string> dict, IReadOnlyList <string> typeParamterNames)
 {
     foreach (var m in from m in type.GetMembers()
              where !(m is INamedTypeSymbol)
              where FilterVisitor.CanVisitApi(m, symbol == type || !symbol.IsSealed || symbol.TypeKind != TypeKind.Struct)
              where IsInheritable(m)
              select m)
     {
         var sig = MemberSigRegex.Replace(SpecIdHelper.GetSpecId(m, typeParamterNames), string.Empty);
         if (!dict.ContainsKey(sig))
         {
             dict.Add(sig, type == symbol ? null : AddSpecReference(m, typeParamterNames));
         }
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }