Exemplo n.º 1
0
        public DocMethodOverload AddOverload(string aSignature)
        {
            DocMethodOverload result = new DocMethodOverload(this, aSignature);

            overloads.Add(result);
            return(result);
        }
Exemplo n.º 2
0
        public DocInheritMethod(DocMethodOverload destination, string reference)
        {
            destinationMethod = destination;
            inheritReference  = reference.Trim();
            int start = inheritReference.IndexOf('.');

            start            = start == -1 ? 0 : start + 1;
            inheritReference = inheritReference.Substring(start);
        }
Exemplo n.º 3
0
        public void Resolve(List <DocMethod> methods)
        {
            string[] segs           = inheritReference.Split('(');
            string   nameSignature  = segs[0];
            string   paramSignature = segs.Length > 1 ? segs[1] : "";

            if (paramSignature.Length > 0)
            {
                paramSignature = paramSignature.Substring(0, paramSignature.Length - 1);
            }

            string[] names   = nameSignature.Split('.');
            string[] mparams = paramSignature.Split(',');
            if (names.Length != 2)
            {
                Console.WriteLine($"Inheritdoc on {destinationMethod.signature} has more components than understood: '{inheritReference}'");
                return;
            }

            for (int i = 0; i < methods.Count; i++)
            {
                if (methods[i].parent.name != names[0] ||
                    methods[i].name != names[1])
                {
                    continue;
                }

                for (int v = 0; v < methods[i].overloads.Count; v++)
                {
                    DocMethodOverload ov = methods[i].overloads[v];
                    if (ov == destinationMethod)
                    {
                        continue;
                    }
                    if (ov.signature == paramSignature)
                    {
                        if (string.IsNullOrEmpty(destinationMethod.summary))
                        {
                            destinationMethod.summary = ov.summary;
                        }
                        if (string.IsNullOrEmpty(destinationMethod.returns))
                        {
                            destinationMethod.returns = ov.returns;
                        }

                        destinationMethod.parameters.InsertRange(0, ov.parameters);
                        return;
                    }
                }
            }
            Console.WriteLine($"Unresolved inheritdoc for {destinationMethod.signature}, reference not found: '{inheritReference}'");
        }
Exemplo n.º 4
0
        static void ReadMethod(string signature, XmlReader reader)
        {
            // Get names
            string[] segs           = signature.Split('(');
            string   nameSignature  = segs[0];
            string   paramSignature = segs.Length > 1?segs[1] :"";

            segs = nameSignature.Split('.');
            if (paramSignature.Length > 0)
            {
                paramSignature = paramSignature.Substring(0, paramSignature.Length - 1);
            }

            DocMethod method = methods.Find(a => a.name == segs[segs.Length - 1] && a.parent.name == segs[segs.Length - 2]);

            if (method == null)
            {
                method = new DocMethod(GetClass(segs[segs.Length - 2]), segs[segs.Length - 1]);
                methods.Add(method);
                items.Add(method);
            }

            DocMethodOverload variant = method.AddOverload(paramSignature);

            // Read properties
            while (reader.Read())
            {
                switch (reader.Name.ToLower())
                {
                case "summary": variant.summary = StringHelper.CleanMultiLine(reader.ReadElementContentAsString().Trim()); break;

                case "returns": variant.returns = StringHelper.CleanMultiLine(reader.ReadElementContentAsString().Trim()); break;

                case "param": {
                    DocParam p = new DocParam();
                    p.name    = reader.GetAttribute("name");
                    p.summary = reader.ReadElementContentAsString().Trim();
                    variant.parameters.Add(p);
                } break;

                case "inheritdoc": {
                    inheritMethods.Add(new DocInheritMethod(variant, reader.GetAttribute("cref")));
                } break;
                }
            }
        }