Exemplo n.º 1
0
        public void XmlDocs_EnumerateProperties()
        {
            if (RunningOnMono)
            {
                return;
            }

            var res = from t in GetTypes()
                      from p in t.GetProperties()
                      where !(t == typeof(string) && p.Name == "Chars")
                      select p;

            foreach (var m in res)
            {
                var d = XmlDocumentation.GetXmlDoc(m);
                Assert.IsNotNull(d, m.ToString() + " on " + m.DeclaringType.ToString());


                foreach (var p in m.GetIndexParameters())
                {
                    var e = XmlDocumentation.GetXmlDoc(p);
                    Assert.IsNotNull(e);
                }
            }
        }
Exemplo n.º 2
0
        private static XmlDocumentation _TranslateAssembly(XElement memberNode, string assemblyName)
        {
            var member = new XmlDocumentation
            {
                AssemblyName = assemblyName,
                Data         = memberNode.Elements().ToList()
            };

            return(memberNode.GetMemberDetails("name", member));
        }
Exemplo n.º 3
0
        public void XmlDocs_EnumerateMethods()
        {
            if (RunningOnMono)
            {
                return;
            }

            var forbiddenPrefixes = new[] { "get_", "set_", "add_", "remove_" };

            var res = from t in GetTypes()
                      from m in t.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
                      where !forbiddenPrefixes.Any(p => m.Name.StartsWith(p))
                      where !(typeof(Delegate).IsAssignableFrom(m.DeclaringType) && m.Name.Contains("Invoke"))
                      select m;

            var exclude = new Dictionary <Type, List <string> >
            {
                { typeof(DateTimeOffset), new List <string> {
                      "FromUnixTimeMilliseconds", "FromUnixTimeSeconds", "ToUnixTimeMilliseconds", "ToUnixTimeSeconds"
                  } },
                { typeof(Buffer), new List <string> {
                      "MemoryCopy"
                  } },
                { typeof(Array), new List <string> {
                      "Empty"
                  } },
                { typeof(string), new List <string> {
                      "Format"
                  } },
                { typeof(GC), new List <string> {
                      "Collect", "EndNoGCRegion", "TryStartNoGCRegion"
                  } },
            };

            foreach (var m in res)
            {
                if (exclude.TryGetValue(m.DeclaringType, out var ex) && ex.Contains(m.Name))
                {
                    continue;
                }

                var d = XmlDocumentation.GetXmlDoc(m);

                Assert.IsNotNull(d, m.ToString() + " on " + m.DeclaringType.ToString());

                foreach (var p in m.GetParameters())
                {
                    var e = XmlDocumentation.GetXmlDoc(p);
                    Assert.IsNotNull(e);
                }
            }
        }
Exemplo n.º 4
0
        public void XmlDocs_EnumerateTypes()
        {
            if (RunningOnMono)
            {
                return;
            }

            foreach (var t in GetTypes())
            {
                var d = XmlDocumentation.GetXmlDoc(t);
                Assert.IsNotNull(d);
            }
        }
        public static string GetCommentSummary(this ISymbol symbol)
        {
            var xmlCommentAsString = symbol.GetDocumentationCommentXml();

            string summary = null;

            try
            {
                summary = new XmlDocumentation(xmlCommentAsString).Summary;
            }
            catch (XmlException)
            {
            }

            return(summary);
        }
Exemplo n.º 6
0
        public void XmlDocs_EnumerateEvents()
        {
            if (RunningOnMono)
            {
                return;
            }

            var res = from t in GetTypes()
                      from e in t.GetEvents()
                      select e;

            foreach (var m in res)
            {
                var d = XmlDocumentation.GetXmlDoc(m);
                Assert.IsNotNull(d, m.ToString() + " on " + m.DeclaringType.ToString());
            }
        }
Exemplo n.º 7
0
        private static MemberDoc _ConvertToMember(MemberInfo memberInfo, XmlDocumentation member, string fileName)
        {
            var link = LinkCache.SetLink(memberInfo.GetLinkKey(),
                                         (memberInfo.IsStatic() ?? false) ? $"{memberInfo.DeclaringType.Name}.{memberInfo.Name}" : memberInfo.Name,
                                         fileName);

            MarkdownGenerator.UpdateLinkForMember(link, memberInfo);

            var doc = new MemberDoc
            {
                AssociatedMember = memberInfo,
                MemberType       = member.MemberType
            };

            doc.Tags.AddRange(member.Data.Select(_ConvertToTag));

            return(doc);
        }
Exemplo n.º 8
0
        public void XmlDocs_EnumerateFields()
        {
            if (RunningOnMono)
            {
                return;
            }

            var res = from t in GetTypes()
                      from f in t.GetFields()
                      where f.Name != "value__" // enums
                      select f;

            foreach (var m in res)
            {
                var d = XmlDocumentation.GetXmlDoc(m);
                Assert.IsNotNull(d, m.ToString() + " on " + m.DeclaringType.ToString());
            }
        }
Exemplo n.º 9
0
        public RoslynMethod(IMethodSymbol methodSymbol, ParseContext context)
        {
            Name = methodSymbol.Name;

            // Documentation
            XmlDocumentation doc = context.DocumentationProvider.GetDocumentationForSymbol(methodSymbol);

            SummaryComments = doc.Summary;
            ReturnsComments = doc.Returns;

            // Attributes
            _attrs = new Lazy <IReadOnlyList <IAttributeData> >(() => RoslynAttributeData.FromSymbol(methodSymbol, context));

            // Return Type
            _returnType = new Lazy <IType>(() =>
            {
                IType returnType = context.GetMethodReturnType(methodSymbol);
                return(returnType);
            });

            // Parameters
            _parameters = new List <IMethodParameter>();
            foreach (IParameterSymbol oneParam in methodSymbol.Parameters)
            {
                string comments = "";
                if (doc.Parameters.ContainsKey(oneParam.Name))
                {
                    comments = doc.Parameters[oneParam.Name];
                }
                RoslynMethodParameter csParam = new RoslynMethodParameter(
                    oneParam,
                    comments,
                    context);

                _parameters.Add(csParam);
            }
        }
Exemplo n.º 10
0
        public void XmlDocs_EnumerateConstructors()
        {
            if (RunningOnMono)
            {
                return;
            }

            var res = from t in GetTypes()
                      where !typeof(Delegate).IsAssignableFrom(t)
                      from c in t.GetConstructors()
                      select c;

            foreach (var m in res)
            {
                var d = XmlDocumentation.GetXmlDoc(m);
                Assert.IsNotNull(d, m.ToString() + " on " + m.DeclaringType.ToString());

                foreach (var p in m.GetParameters())
                {
                    var e = XmlDocumentation.GetXmlDoc(p);
                    Assert.IsNotNull(e);
                }
            }
        }
Exemplo n.º 11
0
 public void XmlDocs_ArgumentChecking()
 {
     Assert.ThrowsException <ArgumentNullException>(() => XmlDocumentation.GetXmlDoc(default(MemberInfo)));
     Assert.ThrowsException <ArgumentNullException>(() => XmlDocumentation.GetXmlDoc(default(ParameterInfo)));
 }
Exemplo n.º 12
0
 public void XmlDocs_GetXmlDocName_ArgumentChecking()
 {
     Assert.ThrowsException <ArgumentNullException>(() => XmlDocumentation.GetXmlDocName(null));
 }
Exemplo n.º 13
0
        public static XmlDocumentation GetMemberDetails(this XElement memberNode, string attributeName, XmlDocumentation member)
        {
            var nameValue = memberNode.Attribute(attributeName)?.Value;

            if (nameValue == null)
            {
                return(null);
            }

            var parts = nameValue.Split(":");

            switch (parts[0])
            {
            case "T":
                member.MemberType = MemberType.Type;
                member.MemberName = parts[1];
                break;

            case "F":
                member.MemberType = MemberType.Field;
                member.MemberName = parts[1];
                break;

            case "P":
                member.MemberType = MemberType.Property;
                member.MemberName = parts[1];
                break;

            case "M":
                if (parts[1].Contains("#ctor"))
                {
                    member.MemberType = MemberType.Constructor;
                }
                else
                {
                    member.MemberType = MemberType.Method;
                }
                member.MemberName = parts[1];
                break;

            case "E":
                member.MemberType = MemberType.Event;
                member.MemberName = parts[1];
                break;
            }

            return(member);
        }