Exemple #1
0
 public override void Build(ECMAStore store)
 {
     if (string.IsNullOrEmpty(Id))
     {
         Id = Name.Replace('+', '.');
         if (Id.Contains('<'))
         {
             Id = GenericRegex.Replace(Id, match => "`" + (match.Value.Count(c => c == ',') + 1));
         }
     }
 }
Exemple #2
0
 public override void Build(ECMAStore store)
 {
     if (TypeArguments?.Count > 0)
     {
         var genericPart = string.Format("<{0}>", string.Join(",", TypeArguments.Select(ta => ta.Value)));
         var uidPart     = "`" + TypeArguments.Count;
         Id = Name.Replace(genericPart, uidPart);
     }
     else
     {
         Id = Name;
     }
     Id = Id.Replace('+', '.');
 }
Exemple #3
0
        private List <string> GetParameterUids(ECMAStore store)
        {
            List <string> ids = new List <string>();

            foreach (var p in Parameters)
            {
                var paraUid = p.Type.Replace('+', '.').Replace('<', '{').Replace('>', '}');
                if (p.RefType == "ref" || p.RefType == "out")
                {
                    paraUid += "@";
                }
                var parent = (Type)Parent;
                paraUid = ReplaceGenericInParameterUid(parent.TypeParameters, "`", paraUid);
                paraUid = ReplaceGenericInParameterUid(TypeParameters, "``", paraUid);
                ids.Add(paraUid);
            }

            return(ids);
        }
Exemple #4
0
        public void BuildName(ECMAStore store)
        {
            DisplayName = ItemType == ItemType.Constructor ? Parent.Name : Name;
            if (DisplayName.StartsWith("op_"))
            {
                DisplayName = DisplayName.Substring("op_".Length);
            }
            var displayNameWithoutEII = DisplayName;

            if (IsEII)
            {
                var typeStr   = DisplayName.Substring(0, DisplayName.LastIndexOf('.'));
                var memberStr = DisplayName.Substring(DisplayName.LastIndexOf('.') + 1);
                DisplayName = typeStr.ToDisplayName() + '.' + memberStr;
            }

            string paramPart = null;

            if (Parameters?.Count > 0)
            {
                if (Name == "op_Explicit" || Name == "op_Implicit")
                {
                    var rtype = ReturnValueType.VersionedTypes.First().Value.ToDisplayName();

                    paramPart = string.Format("({0} to {1})", Parameters.First().Type.ToDisplayName(), rtype);
                }
                else if (IsIndexer)
                {
                    paramPart = string.Format("[{0}]", string.Join(", ", Parameters.Select(p => p.Type.ToDisplayName())));
                }
                else
                {
                    paramPart = string.Format("({0})", string.Join(", ", Parameters.Select(p => p.Type.ToDisplayName())));
                }
            }
            else if (ItemType == ItemType.Method || ItemType == ItemType.Constructor)
            {
                paramPart = "()";
            }
            DisplayName    += paramPart;
            FullDisplayName = ((Type)Parent).FullName + "." + displayNameWithoutEII + paramPart;
        }
Exemple #5
0
 public override void Build(ECMAStore store)
 {
     Id = Name;
 }
Exemple #6
0
 public abstract void Build(ECMAStore store);
Exemple #7
0
        //The ID of a generic method uses postfix ``n, n is the count of in method parameters, for example, System.Tuple.Create``1(``0)
        public override void Build(ECMAStore store)
        {
            if (DocId != null && DocId.Contains('|'))
            {
                var parts = DocId.Split(':');
                if (parts?.Length == 2)
                {
                    Id = parts[1];
                    if (Id.StartsWith(Parent.Uid))
                    {
                        Id = Id.Substring(Parent.Uid.Length, Id.Length - Parent.Uid.Length).TrimStart('.');
                        return;
                    }
                }
            }
            Id = Name.Replace('.', '#');
            if (TypeParameters?.Count > 0)
            {
                Id = Id.Substring(0, Id.LastIndexOf('<')) + "``" + TypeParameters.Count;
            }
            //handle eii prefix
            Id = Id.Replace('<', '{').Replace('>', '}');
            Id = Id.Replace(',', '@');
            if (Parameters?.Count > 0)
            {
                //Type conversion operator can be considered a special operator whose name is the UID of the target type,
                //with one parameter of the source type.
                //For example, an operator that converts from string to int should be Explicit(System.String to System.Int32).
                if (Name == "op_Explicit" || Name == "op_Implicit")
                {
                    var typeParamsOnType   = Parent.TypeParameters?.Select(tp => tp.Name).ToList();
                    var typeParamsOnMember = TypeParameters?.Select(tp => tp.Name).ToList();

                    var rtype = ReturnValueType.VersionedTypes.First().Value;

                    Id += string.Format("({0})~{1}",
                                        Parameters.First().Type.ToSpecId(typeParamsOnType, typeParamsOnMember),
                                        rtype.ToSpecId(typeParamsOnType, typeParamsOnMember));
                }
                //spec is wrong, no need to treat indexer specially, so comment this part out
                //else if (MemberType == MemberType.Property && Signatures.ContainsKey("C#") && Signatures["C#"].Contains("["))
                //{
                //    Id += string.Format("[{0}]", string.Join(",", GetParameterUids(store)));
                //}
                else
                {
                    Id += string.Format("({0})", string.Join(",", GetParameterUids(store)));
                }
            }

            //special handling for compatibility in UWP legacy MD content
            if (store.UWPMode && DocId != null)
            {
                var pos1 = Id.IndexOf('(');
                var pos2 = DocId.IndexOf('(');
                if (pos1 > 0 && pos2 > 0)
                {
                    Id = Id.Substring(0, pos1) + DocId.Substring(pos2);
                }
            }
        }