Exemplo n.º 1
0
        /// <summary>
        /// Thiashd iahsd haishd iashd ihasih iqwhei hqie hwqih eoqwh eoqwihe oashd   
        /// oasihd o oiahsd oihasd oihawoidh aowihd oaihd oiahsoid had asd .as.d as. d  
        /// as.d a sd as.
        /// </summary>
        /// <param name="fieldDefinition"></param>
        /// <param name="declaringType"></param>
        public MyFieldInfo(FieldDefinition fieldDefinition, MyClassInfo declaringType)
            : base()
        {
            this.name = fieldDefinition.Name;

            string[] readableForms = Tools.GetHumanReadableForms(fieldDefinition.FieldType);

            this.typeFullName = readableForms[0];
            this.typeFullNameWithoutRevArrayStrings = readableForms[1];
            this.attributes = GetMyFieldAttributes(fieldDefinition);
            this.declaringType = declaringType;

            if ((fieldDefinition.Attributes & FieldAttributes.HasDefault) != 0)
            {
                try
                {
                    object rawConstant = fieldDefinition.Constant;

                    defaultValue = rawConstant == null ? null : rawConstant.ToString();
                }
                catch (Exception)
                {
                    Logger.Warning("Couldn't obtain default value for field '{0}'.", name);
                }
            }

            this.CheckSupport(fieldDefinition.Attributes);
        }
Exemplo n.º 2
0
        public MyPropertyInfo(PropertyDefinition propertyDefinition, MyClassInfo declaringType)
            : base()
        {
            this.name = propertyDefinition.Name;

            string[] readableForms = Tools.GetHumanReadableForms(propertyDefinition.PropertyType);

            this.typeFullName = readableForms[0];
            this.typeFullNameWithoutRevArrayStrings = readableForms[1];
            this.declaringType = declaringType;

            MethodDefinition getterInfo = propertyDefinition.GetMethod;
            MethodDefinition setterInfo = propertyDefinition.SetMethod;

            this.hasGetter = getterInfo != null;
            this.hasSetter = setterInfo != null;

            MethodDefinition getterOrSetterInfo = getterInfo != null ? getterInfo : setterInfo;
            Debug.Assert(getterOrSetterInfo != null, "Impossible! Property must have either getter or setter or both.");

            this.attributes = GetMyPropertyAttributes(propertyDefinition);
            this.underlyingMethodsAttributes = GetMyInvokableMemberAttributes(getterOrSetterInfo);

            this.parametersNames = new List<string>();
            this.parameters = new Dictionary<string, MyParameterInfo>();

            this.exceptionsDescrs = new List<ExceptionDescr>();

            AddParameters(getterInfo, setterInfo);

            this.CheckSupport(propertyDefinition.Attributes, getterOrSetterInfo.Attributes);
        }
Exemplo n.º 3
0
    public MyConstructorInfo(MethodDefinition constructorDefinition, MyClassInfo declaringType)
      : base(constructorDefinition, declaringType)
    {
      this.name = declaringType.Name;

      this.CheckSupport(constructorDefinition.Attributes);

      AddParameters(constructorDefinition.Parameters);
    }
Exemplo n.º 4
0
        protected MyInvokableMemberInfo(MethodDefinition methodDefinition, MyClassInfo declaringType)
        {
            this.attributes = GetMyInvokableMemberAttributes(methodDefinition);
            this.declaringType = declaringType;

            this.summary = String.Empty;

            this.parametersNames = new List<string>();
            this.parameters = new Dictionary<string, MyParameterInfo>();

            this.exceptionsDescrs = new List<ExceptionDescr>();
        }
Exemplo n.º 5
0
        public ExceptionDescr(string exceptionCref, string condition)
        {
            if (exceptionCref == null)
            {
                throw new ArgumentNullException("exceptionCref");
            }

            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }

            this.exceptionClassInfo = null;
            this.typeFullName = exceptionCref;
            this.condition = condition;
        }
Exemplo n.º 6
0
    public MyEventInfo(EventDefinition eventDefinition, MyClassInfo declaringType)
      : base()
    {
      this.name = eventDefinition.Name;

      string[] readableForms = Tools.GetHumanReadableForms(eventDefinition.EventType);
      this.typeFullName = readableForms[0];
      this.typeFullNameWithoutRevArrayStrings = readableForms[1];

      this.declaringType = declaringType;

      MethodDefinition adderInfo = eventDefinition.AddMethod;
      Debug.Assert(adderInfo != null, "Impossible! add_Event() must have been generated.");

      this.attributes = GetMyEventAttributes(eventDefinition);
      this.underlyingMethodsAttributes = GetMyInvokableMemberAttributes(adderInfo);

      this.CheckSupport(eventDefinition, adderInfo.Attributes);
    }
Exemplo n.º 7
0
    public MyNestedTypeInfo(TypeDefinition typeDefinition, MyClassInfo declaringType)
      : base()
    {
      Debug.Assert(Utils.IsTypeNested(typeDefinition), "Impossible! Given type is not a nested type.");

      string[] readableForms = Tools.GetHumanReadableForms(typeDefinition);
      this.name = readableForms[0];

      int indexOfLastSlash = this.name.LastIndexOf('/');
      Debug.Assert(indexOfLastSlash != -1 && indexOfLastSlash + 1 < this.Name.Length, "Impossible! This is a nested type.");

      this.name = this.name.Substring(indexOfLastSlash + 1);

      this.attributes = MyClassInfo.GetMyClassAttributes(typeDefinition);
      this.declaringType = declaringType;

      this.metaType = GetMetaType(typeDefinition);

      if (metaType == NestedTypes.Unknown)
      {
        Logger.Warning("Unrecognized meta type of '{0}'", typeDefinition.FullName);
      }
    }
Exemplo n.º 8
0
    public MyMethodInfo(MethodDefinition methodDefinition, MyClassInfo declaringType)
      : base(methodDefinition, declaringType)
    {
      this.name = null;

      if ((methodDefinition.Attributes & MethodAttributes.SpecialName) != 0)
      {
        if (MethodsNamesMappings.ContainsKey(methodDefinition.Name))
        {
          this.name = MethodsNamesMappings[methodDefinition.Name];
        }
      }

      if (this.name == null)
      {
        this.name = methodDefinition.Name;
      }

      if (Utils.IsGenericMethod(methodDefinition))
      {
        Tools.ExamineGenericParameters(methodDefinition.GenericParameters, null, out genericParameters);
      }

      if (genericParameters != null && genericParameters.Count > 0)
      {
        this.name += Tools.CreateFormalGenericParametersString(genericParameters);
      }

      string[] readableForms = Tools.GetHumanReadableForms(methodDefinition.ReturnType);
      this.returnTypeFullName = readableForms[0];
      this.returnTypeFullNameWithoutRevArrayStrings = readableForms[1];

      this.CheckSupport(methodDefinition.Attributes);

      AddParameters(methodDefinition.Parameters);
    }
Exemplo n.º 9
0
        public ExceptionDescr(MyClassInfo exceptionClassInfo, string condition)
        {
            if (exceptionClassInfo == null)
            {
                throw new ArgumentNullException("exceptionClassInfo");
            }

            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }

            if (exceptionClassInfo.Namespace == null || exceptionClassInfo.Namespace == "")
            {
                this.typeFullName = exceptionClassInfo.Name;
            }
            else
            {
                this.typeFullName = exceptionClassInfo.Namespace + "." + exceptionClassInfo.Name;
            }

            this.exceptionClassInfo = exceptionClassInfo;
            this.condition = condition;
        }
Exemplo n.º 10
0
    private void ProcessEvent(MyEventInfo myEventInfo, MyClassInfo declaringType, string dirName)
    {
      string syntax = String.Format("{0} event {1} {2}", myEventInfo.AttributesString,
                                                         ProcessType(myEventInfo.TypeFullName),
                                                         myEventInfo.DisplayableName);

      ProcessFieldOrEvent("E_", myEventInfo.Name, "Field", declaringType, dirName,
                          myEventInfo.Summary, myEventInfo.Remarks, syntax, myEventInfo.Example);


    }
Exemplo n.º 11
0
    private void ProcessField(MyFieldInfo myFieldInfo, MyClassInfo declaringType, string dirName)
    {
      string constValue = "";
      if (myFieldInfo.IsConst)
      {
        if (myFieldInfo.ConstantValue == null)
        {
          constValue = " = null";
        }
        else if (myFieldInfo.TypeFullName.ToLower() == "system.string")
        {
          constValue = " = \"" + myFieldInfo.ConstantValue + "\"";
        }
        else
        {
          constValue = " = " + myFieldInfo.ConstantValue;
        }
      }

      string syntax = String.Format("{0} {1} {2}{3}", myFieldInfo.AttributesString,
                                                      ProcessType(myFieldInfo.TypeFullName),
                                                      myFieldInfo.DisplayableName,
                                                      constValue);

      ProcessFieldOrEvent("F_", myFieldInfo.Name, "Field", declaringType, dirName,
                          myFieldInfo.Summary, myFieldInfo.Remarks, syntax, myFieldInfo.Example);
    }
Exemplo n.º 12
0
    private void CreatePropertiesOverloadsIndex(MyPropertiesOverloadsInfo myPropertiessOverloadsInfo, MyClassInfo declaringType, string dirName)
    {
      Debug.Assert(myPropertiessOverloadsInfo.Count > 1, "Impossible! We don't create overloads index when there are no overloads.");

      string prefix = "PO_";

      string fileName = Utils.CombineMultiplePaths(dirName, prefix + GetMyPropertyInfoVisibilitModifiersCodeString(myPropertiessOverloadsInfo[0]) + "_" + myPropertiessOverloadsInfo.Name + "_" + myPropertiessOverloadsInfo.Name.GetHashCode() + ".html");

      FileStream fs = new FileStream(GetAliasName(fileName), FileMode.Create, FileAccess.Write);
      StreamWriter sw = new StreamWriter(fs);

      string pageTitle = String.Format("{0}.{1} Property", Utils.HTMLEncode(declaringType.DisplayableName), Utils.HTMLEncode(myPropertiessOverloadsInfo[0].DisplayableName));

      string[] sectionsNamesAndIndices = { "Overload List:0" };
      int sectionIndex = 0;

      WriteIndexHeader(sw, pageTitle, sectionsNamesAndIndices);

      WriteIndexSummary(sw, myPropertiessOverloadsInfo.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 (MyPropertyInfo myPropertyInfo in myPropertiessOverloadsInfo)
      {
        IconsTypes iconsTypes = GetIconsTypes(myPropertyInfo, 0, 0);

        index++;

        string link = ResolvePropertyLink(myPropertyInfo, declaringType, index);

        string displayableName = Utils.HTMLEncode(myPropertyInfo.DisplayableName);
        string name = Utils.HTMLEncode(declaringType.DisplayableName + "." + displayableName + " (");

        if (myPropertyInfo.Parameters.Count > 0)
        {
          bool first = true;
          foreach (string parameterName in myPropertyInfo.ParametersNames)
          {
            MyParameterInfo myParameterInfo = myPropertyInfo.Parameters[parameterName];
            string processedType = ProcessType(myParameterInfo.TypeFullName);

            if (!first)
            {
              name += ", ";
            }

            name += processedType;

            first = false;
          }
        }

        WriteIndexMembersTableRow(sw,
                                  name + ")",
                                  link,
                                  myPropertyInfo.Summary,
                                  Icons.GetFileNames(iconsTypes),
                                  Icons.GetAltLabels(iconsTypes));
      }

      WriteIndexMembersTableEnd(sw);

      WriteIndexSectionEnd(sw);

      WriteIndexFooter(sw);

      sw.Close();
      fs.Close();
    }
Exemplo n.º 13
0
    private string CreateNamespaceMemberSyntaxTable(MyClassInfo namespaceMember, string name, string metaName)
    {
      StringBuilder sb = new StringBuilder();

      sb.Append("<table style=\"width: 100%;\" class=\"InsideCodeBlock\">\n");

      sb.Append("<col width=\"0%\" />\n");
      sb.Append("<col width=\"100%\" />\n");

      string baseTypeName = null;

      if (namespaceMember is MyEnumerationInfo)
      {
        baseTypeName = ((MyEnumerationInfo)namespaceMember).UnderlyingTypeFullName;
      }
      else if (!(namespaceMember is MyStructureInfo) && !(namespaceMember is MyDelegateInfo) && !(namespaceMember is MyInterfaceInfo))
      {
        if (namespaceMember.BaseTypeName != null && namespaceMember.BaseTypeName.ToLower() != "system.object")
        {
          baseTypeName = namespaceMember.BaseTypeName;
        }
      }

      bool hasBaseTypeOrInterfaces = baseTypeName != null || namespaceMember.ImplementedInterfacesNames.Count > 0;

      sb.Append("<tr>\n");
      sb.Append(String.Format("<td class=\"NoWrapTop\">{0} {1} {2} {3}</td>\n", namespaceMember.AttributesString,
                                                                                metaName,
                                                                                name,
                                                                                hasBaseTypeOrInterfaces ? ":&nbsp;" : ""));

      if (hasBaseTypeOrInterfaces)
      {
        sb.Append("<td>\n");

        if (baseTypeName != null)
        {
          sb.Append(ProcessType(baseTypeName));
        }

        if (!(namespaceMember is MyEnumerationInfo))
        {
          string implementedInterfaces = GetImlpementedInterfacesString(namespaceMember.ImplementedInterfacesNames);

          if (baseTypeName != null)
          {
            if (implementedInterfaces != "")
            {
              sb.Append(',');
            }

            sb.Append("<br />");
          }

          sb.Append(implementedInterfaces);
        }

        sb.Append("\n</td>\n");
      }
      else
      {
        sb.Append("<td>&nbsp;</td>\n");
      }

      sb.Append("</tr>\n");
      sb.Append("</table>\n");

      if (namespaceMember.GenericParametersCount > 0 && namespaceMember.ContainsGenericParameterWithConstraints)
      {
        WriteGenericParametersConstraints(namespaceMember.GenericParameters, sb);
      }

      return sb.ToString();
    }
Exemplo n.º 14
0
    private string ResolvePropertyLink(MyPropertyInfo myPropertyInfo, MyClassInfo declaringType,
                                       int indexInOverloadsList)
    {
      string prefix = "P_" + GetMyPropertyInfoVisibilitModifiersCodeString(myPropertyInfo) + "_";
      string namespaceDirName = GetNamespaceDirName(declaringType.Namespace);

      return GetAliasName(declaringType.AssemblyName + "_" + declaringType.AssemblyName.GetHashCode()
                        + Path.DirectorySeparatorChar + namespaceDirName
                        + Path.DirectorySeparatorChar + CLASS_MEMBERS_DIRECTORY
                        + Path.DirectorySeparatorChar + declaringType.Name + "_" + declaringType.Name.GetHashCode()
                        + Path.DirectorySeparatorChar + prefix + myPropertyInfo.Name + "_" + indexInOverloadsList + "_" + myPropertyInfo.Name.GetHashCode() + ".html",
                          true, true);
    }
Exemplo n.º 15
0
    private string[] ObtainListOfMembersSectionsNames(MyClassInfo myClassInfo)
    {
      if (myClassInfo is MyEnumerationInfo || myClassInfo is MyDelegateInfo)
      {
        Debug.Assert(false, String.Format("Impossible! We don't want to create member's index of type '{0}'.", myClassInfo.GetType()));
        return null;
      }

      List<string> result = new List<string>();

      int classMembersGroupTypeIndex = 0;
      int sectionIndex = 0;
      while (Enum.IsDefined(typeof(ClassMembersGroups), classMembersGroupTypeIndex))
      {
        ClassMembersGroups classMembersGroupType = (ClassMembersGroups)classMembersGroupTypeIndex;

        if (myClassInfo.GetMembersCount(classMembersGroupType) > 0)
        {
          string sectionName = MyClassInfo.ClassMembersGroupsToString(classMembersGroupType);
          int tmpSectionIndex = sectionIndex;

          tmpSectionIndex++;
          if (myClassInfo.HasProtectedInternalGroupOfTheSameType(classMembersGroupType))
          {
            sectionName += String.Format(" ${{SectionReference:{0}:{1}}}", tmpSectionIndex, "Protected Internal");
          }

          tmpSectionIndex++;
          if (myClassInfo.HasProtectedGroupOfTheSameType(classMembersGroupType))
          {
            sectionName += String.Format(" ${{SectionReference:{0}:{1}}}", tmpSectionIndex, "Protected");
          }

          tmpSectionIndex++;
          if (myClassInfo.HasInternalGroupOfTheSameType(classMembersGroupType))
          {
            sectionName += String.Format(" ${{SectionReference:{0}:{1}}}", tmpSectionIndex, "Internal");
          }

          tmpSectionIndex++;
          if (myClassInfo.HasPrivateGroupOfTheSameType(classMembersGroupType))
          {
            sectionName += String.Format(" ${{SectionReference:{0}:{1}}}", tmpSectionIndex, "Private");
          }

          result.Add(sectionName);
        }

        classMembersGroupTypeIndex++;
        sectionIndex++;
      }

      return result.ToArray();
    }
Exemplo n.º 16
0
    private void AddGenericNameMappingIfNeeded(MyClassInfo myClassInfo, NamespaceMembersGroups namespaceMembersGroupType)
    {
      if (!myClassInfo.Name.Contains("<"))
      {
        return;
      }

      Dictionary<string, string> genericNamesMappingsForGroup = GetGenericNamesMappingsForGroup(namespaceMembersGroupType);
      string xmlName = Utils.ConvertNameToXmlDocForm(myClassInfo.Name);

      genericNamesMappingsForGroup[xmlName] = myClassInfo.Name;
    }
Exemplo n.º 17
0
    private void ProcessNamespaceMemberMembers(MyClassInfo namespaceMember, NamespaceMembersGroups namespaceMembersGroupType)
    {
      switch (namespaceMembersGroupType)
      {
        case NamespaceMembersGroups.PublicClasses: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.PublicStructures: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.PublicInterfaces: { ProcessInterfaceMembers((MyInterfaceInfo)namespaceMember); break; }
        case NamespaceMembersGroups.PublicDelegates: { break; }
        case NamespaceMembersGroups.PublicEnumerations: { ProcessEnumerationMembers((MyEnumerationInfo)namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedInternalClasses: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedInternalStructures: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedInternalInterfaces: { ProcessInterfaceMembers((MyInterfaceInfo)namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedInternalDelegates: { break; }
        case NamespaceMembersGroups.ProtectedInternalEnumerations: { ProcessEnumerationMembers((MyEnumerationInfo)namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedClasses: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedStructures: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedInterfaces: { ProcessInterfaceMembers((MyInterfaceInfo)namespaceMember); break; }
        case NamespaceMembersGroups.ProtectedDelegates: { break; }
        case NamespaceMembersGroups.ProtectedEnumerations: { ProcessEnumerationMembers((MyEnumerationInfo)namespaceMember); break; }
        case NamespaceMembersGroups.InternalClasses: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.InternalStructures: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.InternalInterfaces: { ProcessInterfaceMembers((MyInterfaceInfo)namespaceMember); break; }
        case NamespaceMembersGroups.InternalDelegates: { break; }
        case NamespaceMembersGroups.InternalEnumerations: { ProcessEnumerationMembers((MyEnumerationInfo)namespaceMember); break; }
        case NamespaceMembersGroups.PrivateClasses: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.PrivateStructures: { ProcessClassOrStructureMembers(namespaceMember); break; }
        case NamespaceMembersGroups.PrivateInterfaces: { ProcessInterfaceMembers((MyInterfaceInfo)namespaceMember); break; }
        case NamespaceMembersGroups.PrivateDelegates: { break; }
        case NamespaceMembersGroups.PrivateEnumerations: { ProcessEnumerationMembers((MyEnumerationInfo)namespaceMember); break; }

        default: { Debug.Assert(false, "Impossible! Couldn't recognize type of namespace member."); break; }
      }
    }
Exemplo n.º 18
0
    public MyNestedTypeInfo GetNestedTypeMember(MyClassInfo physicalClass)
    {
      int indexOfLastPlus = physicalClass.Name.LastIndexOf('/');
      Debug.Assert(indexOfLastPlus != -1 && indexOfLastPlus + 1 < physicalClass.Name.Length, "Impossible! Trying to get nested type for a type which is not nested.");

      if (indexOfLastPlus == -1)
      {
        return null;
      }

      string memberName = physicalClass.Name.Substring(indexOfLastPlus + 1);
      MyNestedTypeInfo nestedType;

      if (physicalClass.IsPublic)
      {
        nestedType = GetMember(ClassMembersGroups.PublicClasses, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PublicStructures, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PublicInterfaces, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PublicDelegates, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PublicEnumerations, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;
      }
      else if (physicalClass.IsProtectedInternal)
      {
        nestedType = GetMember(ClassMembersGroups.ProtectedInternalClasses, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedInternalStructures, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedInternalInterfaces, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedInternalDelegates, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedInternalEnumerations, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;
      }
      else if (physicalClass.IsProtected)
      {
        nestedType = GetMember(ClassMembersGroups.ProtectedClasses, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedStructures, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedInterfaces, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedDelegates, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.ProtectedEnumerations, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;
      }
      else if (physicalClass.IsInternal)
      {
        nestedType = GetMember(ClassMembersGroups.InternalClasses, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.InternalStructures, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.InternalInterfaces, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.InternalDelegates, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.InternalEnumerations, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;
      }
      else if (physicalClass.IsPrivate)
      {
        nestedType = GetMember(ClassMembersGroups.PrivateClasses, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PrivateStructures, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PrivateInterfaces, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PrivateDelegates, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;

        nestedType = GetMember(ClassMembersGroups.PrivateEnumerations, memberName) as MyNestedTypeInfo;
        if (nestedType != null) return nestedType;
      }
      else
      {
        Debug.Assert(false, "Impossible! Unsupported type visibility.");
      }

      return null;
    }
Exemplo n.º 19
0
    private static bool ReturnTypesMatch(string csTypeFullName, string xmlTypeFullName, MyClassInfo memberDeclaringType, List<MyGenericParameterInfo> memberGenericParameters)
    {
      string almostXmlRepresentation = MyParameterInfo.GetXMLCompatibleRepresentation(csTypeFullName, false, false);
      string almostCSRepresentation = GetAlmostCSRepresentation(xmlTypeFullName, memberDeclaringType, memberGenericParameters);

      return almostXmlRepresentation == almostCSRepresentation;
    }
Exemplo n.º 20
0
    private static string GetAlmostCSRepresentation(string xmlParamType, MyClassInfo memberDeclaringType, List<MyGenericParameterInfo> memberGenericParameters)
    {
      string result;

      if (xmlParamType.Contains("`"))
      {
        // resolve generic parameters

        result = new MatchEvaluatorWrapper(memberDeclaringType, memberGenericParameters).Process(xmlParamType);
      }
      else
      {
        result = xmlParamType;
      }

      return result.Replace('{', '<').Replace('}', '>');
    }
Exemplo n.º 21
0
 public MatchEvaluatorWrapper(MyClassInfo memberDeclaringType, List<MyGenericParameterInfo> memberGenericParameters)
 {
   _memberDeclaringType = memberDeclaringType;
   _memberGenericParameters = memberGenericParameters;
 }
Exemplo n.º 22
0
 private static MyGenericParameterInfo FindGenericParameter(MyClassInfo myClassInfo, string typeParamName)
 {
   return myClassInfo.FindGenericParameter(typeParamName);
 }
Exemplo n.º 23
0
    private void ProcessFieldOrEvent(string prefix, string name, string metaName, MyClassInfo declaringType, string dirName, string summary, string remarks, string syntax, string example)
    {
      string fileName = Utils.CombineMultiplePaths(dirName, prefix + name + "_" + 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 pageTitle = String.Format("{0}.{1} {2}", Utils.HTMLEncode(declaringType.DisplayableName), name, metaName);
      string[] sectionsNamesAndIndices;

      if (remarks == null || remarks == "")
      {
        if (example == null || example == "")
        {
          sectionsNamesAndIndices = new string[] { "Syntax:0" };
        }
        else
        {
          sectionsNamesAndIndices = new string[] { "Syntax:0", "Example:1" };
        }
      }
      else
      {
        if (example == null || example == "")
        {
          sectionsNamesAndIndices = new string[] { "Syntax:0", "Remarks:1" };
        }
        else
        {
          sectionsNamesAndIndices = new string[] { "Syntax:0", "Remarks:1", "Example:2" };
        }
      }

      int sectionIndex = 0;

      WriteIndexHeader(sw, pageTitle, sectionsNamesAndIndices);

      WriteIndexSummary(sw, summary);

      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);

      WriteIndexCodeBlockTable(sw, DEFAULT_LANGUAGE, syntax);
      WriteIndexSectionEnd(sw);

      sectionIndex++;

      if (remarks != "")
      {
        WriteIndexSectionBegin(sw,
                               sectionsNamesAndIndices[sectionIndex].Substring(0, sectionsNamesAndIndices[sectionIndex].LastIndexOf(':')),
                               sectionIndex);

        WriteIndexRemarks(sw, remarks);

        WriteIndexSectionEnd(sw);

        sectionIndex++;
      }

      if (example != "")
      {
        string sectionName = sectionsNamesAndIndices[sectionIndex].Substring(0, sectionsNamesAndIndices[sectionIndex].LastIndexOf(':'));

        Debug.Assert(sectionName == "Example", "There should be 'Example' section now.");

        WriteIndexSectionBegin(sw, sectionName, sectionIndex);
        WriteIndexExample(sw, example);
        WriteIndexSectionEnd(sw);

        sectionIndex++;
      }

      WriteIndexFooter(sw);

      sw.Close();
      fs.Close();
    }
Exemplo n.º 24
0
    private void ProcessClassOrStructureMembers(MyClassInfo myClassOrStructureInfo)
    {
      string namespaceDirName = GetNamespaceDirName(myClassOrStructureInfo.Namespace);
      string dirName = Utils.CombineMultiplePaths(myClassOrStructureInfo.AssemblyName + "_" + myClassOrStructureInfo.AssemblyName.GetHashCode(),
                                                  namespaceDirName,
                                                  CLASS_MEMBERS_DIRECTORY,
                                                  myClassOrStructureInfo.Name + "_" + myClassOrStructureInfo.Name.GetHashCode());

      List<MetaClass> fields = myClassOrStructureInfo.GetMembers(ClassMembersGroups.PublicFields);

      fields.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedFields));
      fields.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedInternalFields));

      if ((options & DocumentationGenerationOptions.IncludeInternalMembers) != 0)
      {
        fields.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.InternalFields));
      }

      if ((options & DocumentationGenerationOptions.IncludePrivateMembers) != 0)
      {
        fields.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.PrivateFields));
      }

      foreach (MyFieldInfo myFieldInfo in fields)
      {
        ProcessField(myFieldInfo, myClassOrStructureInfo, dirName);
      }

      List<MetaClass> constructorsOverloads = myClassOrStructureInfo.GetMembers(ClassMembersGroups.PublicConstructors);

      constructorsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedConstructors));
      constructorsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedInternalConstructors));

      if ((options & DocumentationGenerationOptions.IncludeInternalMembers) != 0)
      {
        constructorsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.InternalConstructors));
      }

      if ((options & DocumentationGenerationOptions.IncludePrivateMembers) != 0)
      {
        constructorsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.PrivateConstructors));
      }

      foreach (MyInvokableMembersOverloadsInfo myInvokableMembersOverloadsInfo in constructorsOverloads)
      {
        ProcessInvokableMembersOverloads(myInvokableMembersOverloadsInfo, myClassOrStructureInfo, dirName);
      }

      List<MetaClass> methodsOverloads = myClassOrStructureInfo.GetMembers(ClassMembersGroups.PublicMethodsOverloads);

      methodsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedMethodsOverloads));
      methodsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedInternalMethodsOverloads));

      if ((options & DocumentationGenerationOptions.IncludeInternalMembers) != 0)
      {
        methodsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.InternalMethodsOverloads));
      }

      if ((options & DocumentationGenerationOptions.IncludePrivateMembers) != 0)
      {
        methodsOverloads.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.PrivateMethodsOverloads));
      }

      foreach (MyInvokableMembersOverloadsInfo myInvokableMembersOverloadsInfo in methodsOverloads)
      {
        ProcessInvokableMembersOverloads(myInvokableMembersOverloadsInfo, myClassOrStructureInfo, dirName);
      }

      List<MetaClass> properties = myClassOrStructureInfo.GetMembers(ClassMembersGroups.PublicPropertiesOverloads);

      properties.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedPropertiesOverloads));
      properties.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedInternalPropertiesOverloads));

      if ((options & DocumentationGenerationOptions.IncludeInternalMembers) != 0)
      {
        properties.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.InternalPropertiesOverloads));
      }

      if ((options & DocumentationGenerationOptions.IncludePrivateMembers) != 0)
      {
        properties.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.PrivatePropertiesOverloads));
      }

      foreach (MyPropertiesOverloadsInfo myPropertiesOverloads in properties)
      {
        ProcessPropertiesOverloads(myPropertiesOverloads, myClassOrStructureInfo, dirName);
      }

      List<MetaClass> events = myClassOrStructureInfo.GetMembers(ClassMembersGroups.PublicEvents);

      events.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedEvents));
      events.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.ProtectedInternalEvents));

      if ((options & DocumentationGenerationOptions.IncludeInternalMembers) != 0)
      {
        events.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.InternalEvents));
      }

      if ((options & DocumentationGenerationOptions.IncludePrivateMembers) != 0)
      {
        events.AddRange(myClassOrStructureInfo.GetMembers(ClassMembersGroups.PrivateEvents));
      }

      foreach (MyEventInfo myEventInfo in events)
      {
        ProcessEvent(myEventInfo, myClassOrStructureInfo, dirName);
      }
    }
Exemplo n.º 25
0
    private string ResolveInvokableMemberLink(MyInvokableMemberInfo myInvokableMemberInfo, MyClassInfo declaringType, int indexInOverloadsList)
    {
      string prefix;

      if (myInvokableMemberInfo is MyConstructorInfo)
      {
        prefix = "C_" + GetMyInvokableMemberVisibilitModifiersCodeString(myInvokableMemberInfo) + "_";
      }
      else
      {
        Debug.Assert(myInvokableMemberInfo is MyMethodInfo, "Impossible!");

        prefix = "M_" + GetMyInvokableMemberVisibilitModifiersCodeString(myInvokableMemberInfo) + "_";
      }

      string namespaceDirName = GetNamespaceDirName(declaringType.Namespace);

      return GetAliasName(declaringType.AssemblyName + "_" + declaringType.AssemblyName.GetHashCode()
                        + Path.DirectorySeparatorChar + namespaceDirName
                        + Path.DirectorySeparatorChar + CLASS_MEMBERS_DIRECTORY
                        + Path.DirectorySeparatorChar + declaringType.Name + "_" + declaringType.Name.GetHashCode()
                        + Path.DirectorySeparatorChar + prefix + myInvokableMemberInfo.Name + "_" + indexInOverloadsList + "_" + myInvokableMemberInfo.Name.GetHashCode() + ".html",
                          true, true);
    }
Exemplo n.º 26
0
    private void ProcessPropertiesOverloads(MyPropertiesOverloadsInfo myPropertiesOverloadsInfo, MyClassInfo declaringType, string dirName)
    {
      if (myPropertiesOverloadsInfo.Count > 1)
      {
        CreatePropertiesOverloadsIndex(myPropertiesOverloadsInfo, declaringType, dirName);
      }

      string prefix = "P_";

      int index = -1;
      foreach (MyPropertyInfo myPropertyInfo in myPropertiesOverloadsInfo)
      {
        index++;
        string fileName = Utils.CombineMultiplePaths(dirName, prefix + GetMyPropertyInfoVisibilitModifiersCodeString(myPropertyInfo) + "_" + myPropertyInfo.Name + "_" + index + "_" + myPropertyInfo.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 myPropertyInfo.ParametersNames)
        {
          MyParameterInfo myParameterInfo = myPropertyInfo.Parameters[paramName];

          if (!first)
          {
            paramsString += ", ";
          }

          paramsString += ProcessType(myParameterInfo.TypeFullName);

          first = false;
        }
        paramsString += ")";

        if (paramsString == "()") { paramsString = ""; }

        string pageTitle = Utils.HTMLEncode(declaringType.DisplayableName) + "." + Utils.HTMLEncode(myPropertyInfo.DisplayableName) + " Property " + paramsString;

        List<string> sectionsNames = new List<string>();

        sectionsNames.Add("Syntax");

        if (myPropertyInfo.ExceptionsDescrs.Count > 0)
        {
          sectionsNames.Add("Exceptions");
        }

        if (myPropertyInfo.Remarks != "")
        {
          sectionsNames.Add("Remarks");
        }

        if (myPropertyInfo.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, myPropertyInfo.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 = CreatePropertySyntaxString(myPropertyInfo);
        WriteIndexCodeBlockTable(sw, DEFAULT_LANGUAGE, syntax);

        WriteParametersAndReturnValueDescriptions(sw, myPropertyInfo.ParametersNames, myPropertyInfo.Parameters,
                                                  ((MyPropertyInfo)myPropertyInfo).TypeFullName,
                                                  ((MyPropertyInfo)myPropertyInfo).ReturnValueSummary,
                                                  true);

        WriteIndexSectionEnd(sw);

        sectionIndex++;

        if (myPropertyInfo.ExceptionsDescrs.Count > 0)
        {
          Debug.Assert(sectionsNames[sectionIndex] == "Exceptions", "Exceptions section was expected.");

          WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex);
          WriteIndexExceptionsTable(sw, myPropertyInfo.ExceptionsDescrs);
          WriteIndexSectionEnd(sw);

          sectionIndex++;
        }

        if (myPropertyInfo.Remarks != "")
        {
          Debug.Assert(sectionsNames[sectionIndex] == "Remarks", "Remarks section was expected.");

          WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex);
          WriteIndexRemarks(sw, myPropertyInfo.Remarks);
          WriteIndexSectionEnd(sw);

          sectionIndex++;
        }

        if (myPropertyInfo.Example != "")
        {
          Debug.Assert(sectionsNames[sectionIndex] == "Example", "There should be 'Example' section now.");

          WriteIndexSectionBegin(sw, sectionsNames[sectionIndex], sectionIndex);
          WriteIndexExample(sw, myPropertyInfo.Example);
          WriteIndexSectionEnd(sw);

          sectionIndex++;
        }

        WriteIndexFooter(sw);

        sw.Close();
        fs.Close();
      }
    }
Exemplo n.º 27
0
    private string[] ObtainListOfMembersSectionsShortcutsNamesAndIndices(MyClassInfo myClassInfo)
    {
      if (myClassInfo is MyEnumerationInfo || myClassInfo is MyDelegateInfo)
      {
        Debug.Assert(false, String.Format("Impossible! We don't want to create member's index of type '{0}'.", myClassInfo.GetType()));
        return null;
      }

      List<string> result = new List<string>();

      int classMembersGroupTypeIndex = 0;
      int sectionIndex = 0;
      while (Enum.IsDefined(typeof(ClassMembersGroups), classMembersGroupTypeIndex))
      {
        ClassMembersGroups classMembersGroupType = (ClassMembersGroups)classMembersGroupTypeIndex;

        if (myClassInfo.GetMembersCount(classMembersGroupType) > 0)
        {
          if (MyClassInfo.IsMembersGroupPublic(classMembersGroupType))
          {
            result.Add(MyClassInfo.GetBaseGroupName(classMembersGroupType) + ":" + sectionIndex);
          }
        }

        classMembersGroupTypeIndex++;
        sectionIndex++;
      }

      return result.ToArray();
    }
Exemplo n.º 28
0
    private string CreateNamespaceMemberSyntaxString(MyClassInfo namespaceMember)
    {
      string name = Utils.HTMLEncode(Utils.GetUnqualifiedName(namespaceMember.DisplayableName));
      string metaName = "class";

      if (namespaceMember is MyStructureInfo) { metaName = "struct"; }
      else if (namespaceMember is MyInterfaceInfo) { metaName = "interface"; }
      else if (namespaceMember is MyDelegateInfo)
      {
        MyDelegateInfo myDelegateInfo = (MyDelegateInfo)namespaceMember;

        List<MyGenericParameterInfo> genericParameters = myDelegateInfo.GenericParametersCount == 0 || !myDelegateInfo.ContainsGenericParameterWithConstraints ? null : myDelegateInfo.GenericParameters;

        return CreateInvokableMemberOrDelegateSyntaxString(myDelegateInfo.AttributesString,
                                                           " " + ProcessType(myDelegateInfo.ReturnTypeFullName),
                                                           name,
                                                           myDelegateInfo.ParametersNames,
                                                           myDelegateInfo.Parameters,
                                                           genericParameters);
      }
      else if (namespaceMember is MyEnumerationInfo) { metaName = "enum"; }

      return CreateNamespaceMemberSyntaxTable(namespaceMember, name, metaName);
    }
Exemplo n.º 29
0
    private string GetDeclaringTypeNameOfANestedType(MyClassInfo myClassInfo)
    {
      int indexOfLastPlus = myClassInfo.Name.LastIndexOf('/');

      if (indexOfLastPlus == -1)
      {
        return null;
      }

      return myClassInfo.Name.Substring(0, indexOfLastPlus);
    }
Exemplo n.º 30
0
    private static bool SignaturesMatch(List<String> memberParametersNames, Dictionary<string, MyParameterInfo> memberParameters, List<string> xmlParamsTypes, MyClassInfo memberDeclaringType, List<MyGenericParameterInfo> memberGenericParameters)
    {
      if (memberParametersNames.Count != xmlParamsTypes.Count)
      {
        return false;
      }

      bool signaturesMatch = true;
      int i = 0;
      foreach (string paramName in memberParametersNames)
      {
        MyParameterInfo myParameterInfo = memberParameters[paramName];

        string almostXmlRepresentation = myParameterInfo.GetXMLCompatibleRepresentation();
        string almostCSRepresentation = GetAlmostCSRepresentation(xmlParamsTypes[i], memberDeclaringType, memberGenericParameters);

        if (almostXmlRepresentation != almostCSRepresentation)
        {
          signaturesMatch = false;
          break;
        }

        i++;
      }

      return signaturesMatch;
    }