/// <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> /// Load additional information from the assembly for this type. /// </summary> private void AddAssemblyInfo(Type type) { if (type.Attributes.IsAbstract()) { Category = TypeCategory.Abstract; } if (type.Attributes.IsStatic()) { Category = TypeCategory.Static; } if (type.Attributes.IsInterface()) { Category = TypeCategory.Interface; } if (type.IsEnum()) { Category = TypeCategory.Enum; } if (type.IsException()) { Category = TypeCategory.Exception; } if (type.IsValueType && !type.IsEnum()) { Category = TypeCategory.Struct; } if (Category == TypeCategory.Unknown) { Category = TypeCategory.Normal; } IsSealed = type.IsSealed; ClassName.AddAssemblyInfo(type); if (type.BaseType != null) { BaseType = new DotNetBaseType(type.BaseType); } Type[] implementedInterfaces = type.GetInterfaces(); if (implementedInterfaces != null) { foreach (Type interfaceType in implementedInterfaces) { ImplementedInterfaces.Add(new DotNetBaseType(interfaceType)); } } foreach (FieldInfo fieldInfo in type.GetDeclaredFields()) { DotNetField field = Fields.FirstOrDefault(f => fieldInfo.Name == f.Name.LocalName); if (field == null) { continue; } field.AddAssemblyInfo(fieldInfo); } foreach (PropertyInfo propertyInfo in type.GetDeclaredProperties().Where(x => x.GetGetMethod() == null || x.GetGetMethod().GetParameters().Count() == 0)) { DotNetProperty property = Properties.FirstOrDefault(p => propertyInfo.Name == DotNetQualifiedName.Combine(p.Name.ExplicitInterface, p.Name.LocalName)); if (property == null) { continue; } property.AddAssemblyInfo(propertyInfo); } foreach (PropertyInfo propertyInfo in type.GetDeclaredProperties().Where(x => x.GetGetMethod() != null && x.GetGetMethod().GetParameters().Count() > 0)) { DotNetIndexer indexer = Properties.OfType <DotNetIndexer>().Cast <DotNetIndexer>().FirstOrDefault(i => i.MatchesSignature(propertyInfo.GetGetMethod())); if (indexer == null) { continue; } indexer.AddAssemblyInfo(propertyInfo); } foreach (MethodInfo methodInfo in type.GetDeclaredMethods()) { DotNetMethod method = Methods.FirstOrDefault(m => m.MatchesSignature(methodInfo)); if (method == null) { continue; } if (methodInfo.Attributes.IsPrivate() && method.Name.ExplicitInterface == null) { Methods.Remove(method); continue; } method.AddAssemblyInfo(methodInfo); } foreach (ConstructorInfo constructorInfo in type.GetDeclaredConstructors()) { DotNetMethodConstructor method = Methods.OfType <DotNetMethodConstructor>().Cast <DotNetMethodConstructor>().FirstOrDefault(m => m.MatchesArguments(constructorInfo.GetParameters())); if (method == null) { continue; } method.AddAssemblyInfo(constructorInfo); } foreach (EventInfo eventInfo in type.GetDeclaredEvents()) { DotNetEvent e = Events.FirstOrDefault(m => m.Name.LocalName == eventInfo.Name); if (e == null) { continue; } e.AddAssemblyInfo(eventInfo); } foreach (Type nestedType in type.GetDeclaredNestedTypes()) { DotNetQualifiedName qualifiedName = DotNetQualifiedName.FromAssemblyInfo(nestedType); DotNetType dotNetNestedType = NestedTypes.FirstOrDefault(x => x.Owns(qualifiedName)); if (dotNetNestedType == null) { continue; } dotNetNestedType.AddAssemblyInfo(type, qualifiedName); } PushGenericTypes(); }