private void CreateInvokableMembersOverloadsIndex(MyInvokableMembersOverloadsInfo myInvokableMembersOverloadsInfo, MyClassInfo declaringType, string dirName) { Debug.Assert(myInvokableMembersOverloadsInfo.Count > 1, "Impossible! We don't create overloads index when there are no overloads."); bool constructors = myInvokableMembersOverloadsInfo[0] is MyConstructorInfo; string prefix = constructors ? "CO_" : "MO_"; string fileName = Utils.CombineMultiplePaths(dirName, prefix + GetMyInvokableMemberVisibilitModifiersCodeString(myInvokableMembersOverloadsInfo[0]) + "_" + myInvokableMembersOverloadsInfo.Name + "_" + myInvokableMembersOverloadsInfo.Name.GetHashCode() + ".html"); FileStream fs = new FileStream(GetAliasName(fileName), FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); string pageTitle; if (constructors) { pageTitle = String.Format("{0} Constructor", Utils.HTMLEncode(declaringType.DisplayableName)); } else { pageTitle = String.Format("{0}.{1} Method", Utils.HTMLEncode(declaringType.DisplayableName), Utils.HTMLEncode(myInvokableMembersOverloadsInfo[0].DisplayableName)); } string[] sectionsNamesAndIndices = { "Overload List:0" }; int sectionIndex = 0; WriteIndexHeader(sw, pageTitle, sectionsNamesAndIndices); WriteIndexSummary(sw, myInvokableMembersOverloadsInfo.SummaryWithoutPrefix); WriteIndexItemLocation(sw, declaringType.DisplayableName, declaringType.Namespace, declaringType.AssemblyName, ResolveNamespaceMemberLink(declaringType.AssemblyName, declaringType.Namespace, declaringType.Name), ResolveNamespaceLink(declaringType.AssemblyName, declaringType.Namespace), ResolveAssemblyLink(declaringType.AssemblyName)); WriteIndexSectionBegin(sw, sectionsNamesAndIndices[sectionIndex].Substring(0, sectionsNamesAndIndices[sectionIndex].LastIndexOf(':')), sectionIndex); WriteIndexMembersTableBegin(sw, DEFAULT_MEMBERS_COLUMNS_NAMES, TYPE_MEMBERS_COLUMNS_WIDTHS); int index = -1; foreach (MyInvokableMemberInfo myInvokableMemberInfo in myInvokableMembersOverloadsInfo) { IconsTypes iconsTypes = GetIconsTypes(myInvokableMemberInfo, 0, 0); index++; string link = ResolveInvokableMemberLink(myInvokableMemberInfo, declaringType, index); string name; if (myInvokableMemberInfo is MyConstructorInfo) { name = myInvokableMemberInfo.DisplayableName + " ("; } else { Debug.Assert(myInvokableMemberInfo is MyMethodInfo, "Impossible!"); name = Utils.HTMLEncode(declaringType.DisplayableName + "." + myInvokableMemberInfo.DisplayableName + " ("); } if (myInvokableMemberInfo.Parameters.Count > 0) { bool first = true; foreach (string parameterName in myInvokableMemberInfo.ParametersNames) { MyParameterInfo myParameterInfo = myInvokableMemberInfo.Parameters[parameterName]; string processedType = ProcessType(myParameterInfo.TypeFullName); if (!first) { name += ", "; } if (myParameterInfo.IsOut) { name += "out "; } else if (myParameterInfo.IsRef) { name += "ref "; } name += processedType; first = false; } } WriteIndexMembersTableRow(sw, name + ")", link, myInvokableMemberInfo.Summary, Icons.GetFileNames(iconsTypes), Icons.GetAltLabels(iconsTypes)); } WriteIndexMembersTableEnd(sw); WriteIndexSectionEnd(sw); WriteIndexFooter(sw); sw.Close(); fs.Close(); }
protected virtual void AddMethod(MethodDefinition methodDefinition) { Debug.Assert(!methodDefinition.IsConstructor); MyMethodInfo myMethodInfo = new MyMethodInfo(methodDefinition, this); Dictionary<string, MetaClass> membersGroup; ClassMembersGroups classMembersGroupType; if (myMethodInfo.IsPublic) { classMembersGroupType = ClassMembersGroups.PublicMethodsOverloads; } else if (myMethodInfo.IsProtectedInternal) { classMembersGroupType = ClassMembersGroups.ProtectedInternalMethodsOverloads; } else if (myMethodInfo.IsProtected) { classMembersGroupType = ClassMembersGroups.ProtectedMethodsOverloads; } else if (myMethodInfo.IsInternal) { classMembersGroupType = ClassMembersGroups.InternalMethodsOverloads; } else if (myMethodInfo.IsPrivate) { classMembersGroupType = ClassMembersGroups.PrivateMethodsOverloads; } else { Debug.Assert(false, "Impossible! Visibility of a member is not supported."); return; } membersGroup = CreateAndGetMembersGroup(classMembersGroupType); MyInvokableMembersOverloadsInfo methodsOverloads; string overloadName = myMethodInfo.Name; bool overloadExists = false; if (myMethodInfo.GenericParametersCount > 0) { overloadName = Utils.ConvertNameToXmlDocForm(myMethodInfo.Name, true); } if (membersGroup.ContainsKey(overloadName)) { var tmpMethodsOverloads = (MyInvokableMembersOverloadsInfo)membersGroup[overloadName]; overloadExists = tmpMethodsOverloads.Count > 0 && tmpMethodsOverloads[0] is MyMethodInfo && ((MyMethodInfo)tmpMethodsOverloads[0]).GenericParametersCount == myMethodInfo.GenericParametersCount; } if (!overloadExists) { methodsOverloads = new MyInvokableMembersOverloadsInfo(myMethodInfo.Name); membersGroup[overloadName] = methodsOverloads; AddGenericNameMappingIfNeeded(myMethodInfo, classMembersGroupType); } else { methodsOverloads = (MyInvokableMembersOverloadsInfo)membersGroup[overloadName]; } methodsOverloads.AddInvokableMember(myMethodInfo); }
private void ProcessInvokableMembersOverloads(MyInvokableMembersOverloadsInfo myInvokableMembersOverloadsInfo, MyClassInfo declaringType, string dirName) { if (myInvokableMembersOverloadsInfo.Count > 1) { CreateInvokableMembersOverloadsIndex(myInvokableMembersOverloadsInfo, declaringType, dirName); } bool constructors = myInvokableMembersOverloadsInfo[0] is MyConstructorInfo; string prefix = constructors ? "C_" : "M_"; int index = -1; foreach (MyInvokableMemberInfo myInvokableMemberInfo in myInvokableMembersOverloadsInfo) { index++; string fileName = Utils.CombineMultiplePaths(dirName, prefix + GetMyInvokableMemberVisibilitModifiersCodeString(myInvokableMemberInfo) + "_" + myInvokableMemberInfo.Name + "_" + index + "_" + myInvokableMemberInfo.Name.GetHashCode() + ".html"); string filename = Utils.CombineMultiplePaths(outputDirectory, CONTENTS_DIRECTORY, GetAliasName(fileName)); FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); string paramsString = "("; bool first = true; foreach (string paramName in myInvokableMemberInfo.ParametersNames) { MyParameterInfo myParameterInfo = myInvokableMemberInfo.Parameters[paramName]; if (!first) { paramsString += ", "; } if (myParameterInfo.IsOut) { paramsString += "out "; } else if (myParameterInfo.IsRef) { paramsString += "ref "; } paramsString += ProcessType(myParameterInfo.TypeFullName); first = false; } paramsString += ")"; string pageTitle; if (constructors) { pageTitle = Utils.HTMLEncode(declaringType.DisplayableName) + " Constructor " + paramsString; } else { pageTitle = Utils.HTMLEncode(declaringType.DisplayableName) + "." + Utils.HTMLEncode(myInvokableMemberInfo.DisplayableName) + " Method " + paramsString; } List<string> sectionsNames = new List<string>(); sectionsNames.Add("Syntax"); if (myInvokableMemberInfo.ExceptionsDescrs.Count > 0) { sectionsNames.Add("Exceptions"); } if (myInvokableMemberInfo.Remarks != "") { sectionsNames.Add("Remarks"); } if (myInvokableMemberInfo.Example != "") { sectionsNames.Add("Example"); } string[] sectionsNamesAndIndices = new string[sectionsNames.Count]; for (int i = 0; i < sectionsNamesAndIndices.Length; i++) { sectionsNamesAndIndices[i] = sectionsNames[i] + ":" + i; } WriteIndexHeader(sw, pageTitle, sectionsNamesAndIndices); WriteIndexSummary(sw, myInvokableMemberInfo.Summary); WriteIndexItemLocation(sw, declaringType.DisplayableName, declaringType.Namespace, declaringType.AssemblyName, ResolveNamespaceMemberLink(declaringType.AssemblyName, declaringType.Namespace, declaringType.Name), ResolveNamespaceLink(declaringType.AssemblyName, declaringType.Namespace), ResolveAssemblyLink(declaringType.AssemblyName)); int sectionIndex = 0; WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex); string syntax = CreateInvokableMemberSyntaxString(myInvokableMemberInfo); WriteIndexCodeBlockTable(sw, DEFAULT_LANGUAGE, syntax); if (myInvokableMemberInfo is MyMethodInfo) { MyMethodInfo myMethodInfo = (MyMethodInfo)myInvokableMemberInfo; if (myMethodInfo.GenericParametersCount > 0) { WriteGenericParametersDescriptions(sw, myMethodInfo.GenericParameters); } } WriteParametersAndReturnValueDescriptions(sw, myInvokableMemberInfo.ParametersNames, myInvokableMemberInfo.Parameters, constructors ? null : ((MyMethodInfo)myInvokableMemberInfo).ReturnTypeFullName, constructors ? null : ((MyMethodInfo)myInvokableMemberInfo).ReturnValueSummary, false); WriteIndexSectionEnd(sw); sectionIndex++; if (myInvokableMemberInfo.ExceptionsDescrs.Count > 0) { Debug.Assert(sectionsNames[sectionIndex] == "Exceptions", "Exceptions section was expected."); WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex); WriteIndexExceptionsTable(sw, myInvokableMemberInfo.ExceptionsDescrs); WriteIndexSectionEnd(sw); sectionIndex++; } if (myInvokableMemberInfo.Remarks != "") { Debug.Assert(sectionsNames[sectionIndex] == "Remarks", "Remarks section was expected."); WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex); WriteIndexRemarks(sw, myInvokableMemberInfo.Remarks); WriteIndexSectionEnd(sw); sectionIndex++; } if (myInvokableMemberInfo.Example != "") { Debug.Assert(sectionsNames[sectionIndex] == "Example", "There should be 'Example' section now."); WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex); WriteIndexExample(sw, myInvokableMemberInfo.Example); WriteIndexSectionEnd(sw); sectionIndex++; } WriteIndexFooter(sw); sw.Close(); fs.Close(); } }
protected virtual void AddConstructor(MethodDefinition constructorDefinition) { Debug.Assert(constructorDefinition.IsConstructor); MyConstructorInfo myConstructorInfo = new MyConstructorInfo(constructorDefinition, this); Dictionary<string, MetaClass> membersGroup; if (myConstructorInfo.IsPublic) { membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.PublicConstructors); } else if (myConstructorInfo.IsProtectedInternal) { membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.ProtectedInternalConstructors); } else if (myConstructorInfo.IsProtected) { membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.ProtectedConstructors); } else if (myConstructorInfo.IsInternal) { membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.InternalConstructors); } else if (myConstructorInfo.IsPrivate) { membersGroup = CreateAndGetMembersGroup(ClassMembersGroups.PrivateConstructors); } else { Debug.Assert(false, "Impossible! Visibility of a member is not supported."); return; } MyInvokableMembersOverloadsInfo constructorsOverloads; if (!membersGroup.ContainsKey(myConstructorInfo.Name)) { constructorsOverloads = new MyInvokableMembersOverloadsInfo(myConstructorInfo.Name); membersGroup[myConstructorInfo.Name] = constructorsOverloads; } else { constructorsOverloads = (MyInvokableMembersOverloadsInfo)membersGroup[myConstructorInfo.Name]; } constructorsOverloads.AddInvokableMember(myConstructorInfo); }