/// <summary> /// Parses a .Net XML documentation type, method, or other member name. /// </summary> /// <param name="name"> /// <list> /// <item>Names starting with "T:" are parsed as Type names.</item> /// <item>Names starting with "M:" are parsed as Method names.</item> /// <item>Names starting with "F:" are parsed as Member names.</item> /// <item>Names starting with "P:" are parsed as Member names.</item> /// <item>Names starting with "E:" are parsed as Member names.</item> /// <item>All others are parsed as Member names.</item> /// </list> /// </param> public static DotNetQualifiedName FromVisualStudioXml(string name) { if (String.IsNullOrEmpty(name)) { return(new DotNetQualifiedName()); } if (name.Length < 2 || name[1] != ':') { return(MemberNameFromVisualStudioXml(name)); } switch (name[0]) { case 'T': return(DotNetQualifiedClassName.FromVisualStudioXml(name)); case 'M': return(DotNetQualifiedMethodName.FromVisualStudioXml(name)); case 'F': case 'P': case 'E': return(MemberNameFromVisualStudioXml(name)); default: return(MemberNameFromVisualStudioXml(name)); } }
/// <summary> /// Returns true if this indexer's signature matches the method signature. /// </summary> public bool Matches(DotNetQualifiedMethodName methodName) { if (methodName.LocalName != "Item") { return(false); } if (methodName.IsGeneric) { return(false); } if (methodName.FullNamespace != this.Name.FullNamespace) { return(false); } if (Parameters.Count != methodName.Parameters.Count) { return(false); } for (int i = 0; i < Parameters.Count; i++) { if (Parameters[i].TypeName != methodName.Parameters[i].TypeName) { return(false); } } return(true); }
/// <summary> /// Parse .Net XML documentation for Indexer data. /// </summary> /// <param name="memberElement">Expects tag name "member".</param> /// <example><![CDATA[<member name="P:Namespace.Type.Item(System.Int32)"></member>]]></example> public static new DotNetIndexer FromVisualStudioXml(XElement memberElement) { string xmlName = memberElement.GetAttributeValue("name"); string xmlParameters = xmlName.Substring(xmlName.IndexOf("(")); xmlName = xmlName.Substring(0, xmlName.IndexOf("(")); DotNetQualifiedName name = DotNetQualifiedName.FromVisualStudioXml(xmlName); List <DotNetParameter> parameters = DotNetQualifiedMethodName.ParametersFromVisualStudioXml(xmlParameters); DotNetIndexer indexer = new DotNetIndexer(name, parameters); indexer.ParseVisualStudioXmlDocumentation(memberElement); return(indexer); }
/// <summary> /// Parse .Net XML documentation for method signature data. /// </summary> /// <param name="memberElement">Expects tag "member".</param> /// <example><![CDATA[<member name="M:Namespace.Type.MethodName(System.Int32,System.String)"></member>]]></example> public static DotNetMethod FromVisualStudioXml(XElement memberElement) { string signature = memberElement.GetAttributeValue("name"); if (signature == null) { return(new DotNetMethod()); } DotNetQualifiedMethodName methodName = DotNetQualifiedMethodName.FromVisualStudioXml(signature); //for constructors bool isConstructor = (methodName.LocalName.EndsWith("#ctor") || methodName.LocalName.EndsWith("#cctor")); bool isStatic = methodName.LocalName.EndsWith("#cctor"); //for destructors bool isDestructor = (methodName.LocalName == "Finalize" && methodName.Parameters.Count == 0); //for operators bool isOperator = methodName.LocalName.StartsWith("op_"); DotNetMethod method = null; if (isConstructor) { method = new DotNetMethodConstructor(methodName, isStatic); } else if (isDestructor) { method = new DotNetMethodDestructor(methodName); } else if (isOperator) { method = new DotNetMethodOperator(methodName); } else { method = new DotNetMethod(methodName); } method.ParseVisualStudioXmlDocumentation(memberElement); return(method); }
/// <summary></summary> public DotNetDelegate(DotNetQualifiedMethodName name) : base(name) { Category = MethodCategory.Delegate; }
/// <summary></summary> public DotNetMethod(DotNetQualifiedMethodName name) : base(name) { }
/// <duplicate cref='DotNetQualifiedMethodName.MatchesLocalSignature(DotNetQualifiedMethodName)'/> public bool MatchesLocalSignature(DotNetQualifiedMethodName name) { return(MethodName.MatchesLocalSignature(name)); }
/// <summary></summary> public DotNetMethodDestructor(DotNetQualifiedMethodName name) : base(name) { Category = MethodCategory.Normal; }
/// <summary>Parses .Net XML documentation cref for methods.</summary> /// <example><![CDATA[<permission cref="Namespace.Type.Method(Type1, Type2)">nested comments and/or plain text</permission>]]></example> public static new DotNetCommentMethodLink FromVisualStudioXml(string cref) { DotNetQualifiedMethodName name = DotNetQualifiedMethodName.FromVisualStudioXml(cref); return(new DotNetCommentMethodLink(name)); }
/// <summary></summary> public DotNetCommentMethodLink(DotNetQualifiedMethodName name) : base(name) { }
/// <summary> /// Returns the selected method, if it exists in this type. /// </summary> /// <param name="FindType">Function that returns the selected type from all known types in the assembly.</param> /// <param name="methodName">Name of method, local to this type.</param> public DotNetMethod FindInheritedMethod(Func <DotNetQualifiedName, DotNetType> FindType, DotNetQualifiedMethodName methodName) { DotNetMethod method = Methods.FirstOrDefault(m => m.MatchesLocalSignature(methodName)); if (method != null) { return(method); } if (BaseType != null) { DotNetType baseType = FindType(BaseType.Name); if (baseType != null) { return(baseType.FindInheritedMethod(FindType, methodName)); } } return(null); }
/// <summary></summary> public DotNetMethodConstructor(DotNetQualifiedMethodName name, bool isStatic = false) : base(name) { Category = (isStatic) ? MethodCategory.Static : MethodCategory.Normal; }