Exemplo n.º 1
0
        public void BuildExtensionMethods(Compiler context)
        {
            List<MethodInfo> extensionMethods = GetExtensionMethods(Reflection).ToList();
            ExtensionMethodLookup = new Dictionary<string, MethodInfo>(extensionMethods.Count);

            foreach (MethodInfo mi in extensionMethods)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("M:{0}.{1}", mi.DeclaringType.FullName, mi.Name);
                if (mi.IsGenericMethodDefinition)
                    sb.Append("`");
                Type[] genericMethodArguments = mi.GetGenericArguments();
                if (genericMethodArguments != null && genericMethodArguments.Length > 0)
                    sb.AppendFormat("`{0}", genericMethodArguments.Length);
                ParameterInfo[] parameters = mi.GetParameters();
                if (parameters != null && parameters.Length > 0)
                {
                    sb.Append("(");
                    sb.Append(string.Join(",", parameters.Select(p => p.ParameterType).Select(pt => pt.ToCref()).ToArray()));
                    sb.Append(")");
                }
                MethodInfo existingExtensionMethod = null;
                if (ExtensionMethodLookup.TryGetValue(sb.ToString(), out existingExtensionMethod))
                {
                    context.LogWarning("Generated Extension Method Cref \"{0}\" is ambiguous\n\tExisting Method: \"{1}\"\n\tNew Method: \"{2}\"", sb.ToString(), existingExtensionMethod, mi);
                }
                else
                {
                    context.LogVerbose("Found Extension Method \"{0}\"\n\tGenerated Cref:\"{1}\"", mi, sb);
                    ExtensionMethodLookup.Add(sb.ToString(), mi);
                }

            }
        }
Exemplo n.º 2
0
 public XElement GetCommentElement(Compiler context, string xid)
 {
     XElement ret = null;
     memberElements.TryGetValue(xid, out ret);
     if (ret == null)
     {
         context.LogWarning("Could not find XML comments for \"{0}\"", xid);
     }
     return ret;
 }