/// <summary>Gets the key for the Method Base being handed in</summary>
        internal static string MethodBaseKey(MethodBase methodBase)
        {
            if (methodBase == null)
            {
                return(null);
            }
            var parameters = methodBase.GetParameters();
            var typeKey    = TypeSpec(methodBase.DeclaringType, false);
            var name       = methodBase.IsConstructor ? "#ctor" : methodBase.Name;

            var parameterList = string.Empty;
            var keyPrefix     = "M:";
            var realName      = new GracefulNamer(methodBase.Name).RealName;

            if (methodBase.DeclaringType?.GetProperty(realName) != null)
            {
                keyPrefix = "P:";
                name      = realName;
            }
            else
            {
                if (parameters.Length > 0)
                {
                    parameterList =
                        "(" + string.Join(",", parameters.Select(p => TypeSpec(p.ParameterType, true))) + ")";
                }
            }
            return(keyPrefix + typeKey + "." + name + parameterList);
        }
        /// <summary>Get the inner text, but also include references from 'see' and 'seealso' elements</summary>
        /// <remarks>
        ///     For references, gets the graceful name of the entry after the last dot before the first parenthesis (i.e. ignores class
        ///     references and parameters)
        /// </remarks>
        private static string TextContent(XmlNode entry)
        {
            var textResult = "";

            foreach (XmlNode child in entry.ChildNodes)
            {
                if (child is XmlElement childElement && childElement.HasAttribute("cref"))
                {
                    var name = childElement.GetAttribute("cref").Split('(').First().Split('.').Last();
                    textResult += new GracefulNamer(name).Regrace;
                }
Exemple #3
0
        /// <summary>
        ///     If the documentation is specific about the number of parameters, prioritize it. If not, split out the number
        ///     of parameters and take the base name. If documentation exists return it, else return the empty string
        /// </summary>
        /// <remarks>With constructors splitting out implies returning the class documentation</remarks>
        private string DocumentationFor(string key)
        {
            if (_documentation.ContainsKey(key))
            {
                return(_documentation[key]);
            }
            var keyWithoutParamCount = key.Split('`')[0];
            var nameToSeach          = new GracefulNamer(keyWithoutParamCount).RealName;

            return(_documentation.ContainsKey(nameToSeach) ? _documentation[nameToSeach] : string.Empty);
        }