Ejemplo n.º 1
0
        private void LoadSystemAssemblyDoc(INMemberReference memberRef, MemberReference typeReference)
        {
            NDocumentApi doc          = null;
            var          assemblyPath = Path.GetFullPath(typeReference.Module.FullyQualifiedName);

            if (!mapModuleToDoc.TryGetValue(assemblyPath, out doc))
            {
                var frameworkPath = Utility.GetFrameworkRootDirectory();
                if (assemblyPath.StartsWith(frameworkPath))
                {
                    var assemblyName      = Path.GetFileNameWithoutExtension(assemblyPath);
                    var assemblyDirectory = Path.GetDirectoryName(assemblyPath);

                    // TODO: improve replace
                    assemblyDirectory = assemblyDirectory.Replace(@"\Framework64\", @"\Framework\");

                    var assemblyXml = Path.Combine(Path.Combine(assemblyDirectory, "en"), assemblyName + ".xml");
                    Logger.Message("Load system documentation [{0}]", assemblyName);
                    doc = NDocumentApi.Load(assemblyXml);
                }
                mapModuleToDoc.Add(assemblyPath, doc);
            }

            if (doc != null)
            {
                memberRef.DocNode = doc.FindMemberDoc(memberRef.Id);
            }
        }
Ejemplo n.º 2
0
        public override void CopyDocumentation(INMemberReference other)
        {
            base.CopyDocumentation(other);
            var otherMethod = other as NMethod;

            if (otherMethod != null)
            {
                if (string.IsNullOrEmpty(ObsoleteMessage) && !string.IsNullOrEmpty(otherMethod.ObsoleteMessage))
                {
                    ObsoleteMessage = otherMethod.ObsoleteMessage;
                }

                if (string.IsNullOrEmpty(ReturnDescription) && !string.IsNullOrEmpty(otherMethod.ReturnDescription))
                {
                    ReturnDescription = otherMethod.ReturnDescription;
                }

                for (int i = 0; i < Parameters.Count; i++)
                {
                    if (string.IsNullOrEmpty(Parameters[i].Description) && !string.IsNullOrEmpty(otherMethod.Parameters[i].Description))
                    {
                        Parameters[i].Description = otherMethod.Parameters[i].Description;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override void CopyDocumentation(INMemberReference other)
        {
            base.CopyDocumentation(other);
            var otherEvent = other as NEvent;

            if (otherEvent != null)
            {
                if (string.IsNullOrEmpty(ObsoleteMessage) && !string.IsNullOrEmpty(otherEvent.ObsoleteMessage))
                {
                    ObsoleteMessage = otherEvent.ObsoleteMessage;
                }
            }
        }
Ejemplo n.º 4
0
        public override void CopyDocumentation(INMemberReference other)
        {
            base.CopyDocumentation(other);
            var otherProperty = other as NProperty;

            if (otherProperty != null)
            {
                if (string.IsNullOrEmpty(ObsoleteMessage) && !string.IsNullOrEmpty(otherProperty.ObsoleteMessage))
                {
                    ObsoleteMessage = otherProperty.ObsoleteMessage;
                }

                if (string.IsNullOrEmpty(ValueDescription) && !string.IsNullOrEmpty(otherProperty.ValueDescription))
                {
                    ValueDescription = otherProperty.ValueDescription;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Fills the generic parameters.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <param name="genericParameterProvider">The generic parameter provider.</param>
        private void FillGenericParameters(INMemberReference member, IGenericParameterProvider genericParameterProvider)
        {
            foreach (var genericParameterDef in genericParameterProvider.GenericParameters)
            {
                var genericParameter = new NGenericParameter
                {
                    HasConstraints                    = genericParameterDef.HasConstraints,
                    HasCustomAttributes               = genericParameterDef.HasCustomAttributes,
                    HasDefaultConstructorConstraint   = genericParameterDef.HasDefaultConstructorConstraint,
                    HasNotNullableValueTypeConstraint = genericParameterDef.HasNotNullableValueTypeConstraint,
                    HasReferenceTypeConstraint        = genericParameterDef.HasReferenceTypeConstraint
                };
                this.FillMemberReference(genericParameter, genericParameterDef);

                // Fill constraint
                foreach (var constraint in genericParameterDef.Constraints)
                {
                    genericParameter.Constraints.Add(GetTypeReference(constraint));
                }

                member.GenericParameters.Add(genericParameter);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Compares the display name of the by two <see cref="INMemberReference"/>.
 /// </summary>
 /// <param name="from">From.</param>
 /// <param name="to">To.</param>
 /// <returns></returns>
 private int CompareByDisplayName(INMemberReference from, INMemberReference to)
 {
     return to.Name.CompareTo(from.Name);
 }
Ejemplo n.º 7
0
        public override void CopyDocumentation(INMemberReference other)
        {
            base.CopyDocumentation(other);
            var otherProperty = other as NProperty;
            if (otherProperty != null)
            {               
                if (string.IsNullOrEmpty(ObsoleteMessage) && !string.IsNullOrEmpty(otherProperty.ObsoleteMessage))
                    ObsoleteMessage = otherProperty.ObsoleteMessage;

                if (string.IsNullOrEmpty(ValueDescription) && !string.IsNullOrEmpty(otherProperty.ValueDescription))
                    ValueDescription = otherProperty.ValueDescription;
            }
        }
Ejemplo n.º 8
0
 public override void CopyDocumentation(INMemberReference other)
 {
     base.CopyDocumentation(other);
     var otherEvent = other as NEvent;
     if (otherEvent != null)
     {
         if (string.IsNullOrEmpty(ObsoleteMessage) && !string.IsNullOrEmpty(otherEvent.ObsoleteMessage))
             ObsoleteMessage = otherEvent.ObsoleteMessage;
     }
 }
Ejemplo n.º 9
0
        private void FillMemberReference(INMemberReference memberRef, MemberReference cecilMemberRef)
        {
            memberRef.Id       = DocIdHelper.GetXmlId(cecilMemberRef);
            memberRef.PageId   = PageIdFunction(memberRef);
            memberRef.Name     = ReplacePrimitive(cecilMemberRef.Name, cecilMemberRef.FullName);
            memberRef.FullName = cecilMemberRef.FullName;

            // Load system documentation if needed
            LoadSystemAssemblyDoc(memberRef, cecilMemberRef);

            var typeDef = cecilMemberRef as TypeReference;

            if (typeDef != null)
            {
                memberRef.IsGenericInstance  = typeDef.IsGenericInstance;
                memberRef.IsGenericParameter = typeDef.IsGenericParameter;
                memberRef.IsArray            = typeDef.IsArray;
                memberRef.IsPointer          = typeDef.IsPointer;
                memberRef.IsSentinel         = typeDef.IsSentinel;
                FillGenericParameters(memberRef, typeDef);

                // Handle generic instance
                var genericInstanceDef = typeDef as GenericInstanceType;

                if (genericInstanceDef != null)
                {
                    memberRef.ElementType = GetTypeReference(genericInstanceDef.ElementType);

                    if (genericInstanceDef.GenericArguments.Count > 0)
                    {
                        foreach (var genericArgumentDef in genericInstanceDef.GenericArguments)
                        {
                            var genericArgument = new NTypeReference();
                            FillMemberReference(genericArgument, genericArgumentDef);
                            memberRef.GenericArguments.Add(genericArgument);
                        }

                        // Remove `number from Name
                        memberRef.Name     = BuildGenericName(typeDef.Name, memberRef.GenericArguments);
                        memberRef.FullName = BuildGenericName(typeDef.FullName, memberRef.GenericArguments);
                    }
                }
                else if (memberRef.GenericParameters.Count > 0)
                {
                    // If generic parameters, than rewrite the name/fullname
                    memberRef.Name     = BuildGenericName(typeDef.Name, memberRef.GenericParameters);
                    memberRef.FullName = BuildGenericName(typeDef.FullName, memberRef.GenericParameters);
                }
            }
            else
            {
                var genericParameterProvider = cecilMemberRef as IGenericParameterProvider;
                if (genericParameterProvider != null)
                {
                    this.FillGenericParameters(memberRef, genericParameterProvider);
                    memberRef.Name     = BuildGenericName(memberRef.Name, memberRef.GenericParameters);
                    memberRef.FullName = BuildGenericName(memberRef.FullName, memberRef.GenericParameters);
                }
            }

            var member = memberRef as NMember;

            // Add custom attributes for this member
            if (member != null && cecilMemberRef is ICustomAttributeProvider)
            {
                var attributes = ((ICustomAttributeProvider)cecilMemberRef).CustomAttributes;
                foreach (var customAttribute in attributes)
                {
                    member.Attributes.Add(CustomAttributeToString(member, customAttribute));
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// The basical documentation inheritence copy &lt;summary&gt;, &lt;remarks&gt;, &lt;webdoc&gt; tags and all other sections
        /// </summary>
        public virtual void CopyDocumentation(INMemberReference crefMember)
        {
            if (string.IsNullOrEmpty(Description) && !string.IsNullOrEmpty(crefMember.Description))
            {
                Description = crefMember.Description;
            }

            if (string.IsNullOrEmpty(Remarks) && !string.IsNullOrEmpty(crefMember.Remarks))
            {
                Remarks = crefMember.Remarks;
            }

            if (WebDocPage == null && crefMember.WebDocPage != null)
            {
                WebDocPage = crefMember.WebDocPage;
            }

            // copy all sections of the reference that are not defined in this member
            if (crefMember.DocNode != null)
            {
                // clone the reference node
                XmlNode newDocNode = crefMember.DocNode.Clone();

                if (DocNode == null)
                {
                    DocNode = newDocNode;
                }
                else
                {
                    HtmlDocument DocNodeContent = new HtmlDocument();
                    DocNodeContent.LoadHtml(DocNode.InnerXml);

                    var sections = DocNodeContent.DocumentNode.SelectNodes("section");
                    if (sections != null)
                    {
                        foreach (var section in sections)
                        {
                            var sectionName = section.Attributes["name"];
                            if (sectionName != null)
                            {
                                string xpath = string.Format("//section[@name=\"{0}\"]", sectionName.Value);
                                var    correspondingSection = newDocNode.SelectSingleNode(xpath);
                                if (correspondingSection != null)
                                {
                                    correspondingSection.InnerXml = section.InnerHtml;
                                }
                                else
                                {
                                    var newSection = newDocNode.OwnerDocument.CreateElement("section");
                                    newSection.SetAttribute("name", sectionName.Value);
                                    var title = section.Attributes["title"];
                                    if (title != null)
                                    {
                                        newSection.SetAttribute("title", title.Value);
                                    }
                                    newSection.InnerXml = section.InnerHtml;
                                    newDocNode.AppendChild(newSection);
                                }
                            }
                        }
                    }
                    DocNode = newDocNode;
                }
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Compares the display name of the by two <see cref="INMemberReference"/>.
 /// </summary>
 /// <param name="from">From.</param>
 /// <param name="to">To.</param>
 /// <returns></returns>
 private int CompareByDisplayName(INMemberReference from, INMemberReference to)
 {
     return(to.Name.CompareTo(from.Name));
 }
Ejemplo n.º 12
0
        public override void CopyDocumentation(INMemberReference other)
        {
            base.CopyDocumentation(other);
            var otherMethod = other as NMethod;
            if (otherMethod != null)
            {
                if(string.IsNullOrEmpty(ObsoleteMessage) && !string.IsNullOrEmpty(otherMethod.ObsoleteMessage))
                    ObsoleteMessage = otherMethod.ObsoleteMessage;

                if(string.IsNullOrEmpty(ReturnDescription) && !string.IsNullOrEmpty(otherMethod.ReturnDescription))
                    ReturnDescription = otherMethod.ReturnDescription;

                for (int i = 0; i < Parameters.Count; i++)
                {
                    if (string.IsNullOrEmpty(Parameters[i].Description) && !string.IsNullOrEmpty(otherMethod.Parameters[i].Description))
                        Parameters[i].Description = otherMethod.Parameters[i].Description;
                }
            }
        }
Ejemplo n.º 13
0
 public virtual void CopyDocumentation(INMemberReference crefMember) { }
Ejemplo n.º 14
0
 public virtual void CopyDocumentation(INMemberReference crefMember)
 {
 }