Replace FullName with CSharpSignature
[mono.git] / mcs / mcs / doc.cs
index d3d3b7e10c94a41fdb26f6dbeb41be39135588db..489a0f9797e6c982683c172ac0540781eee61965 100644 (file)
@@ -4,9 +4,9 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Licensed under the terms of the GNU GPL
+// Dual licensed under the terms of the MIT X11 or GNU GPL
 //
-// (C) 2004 Novell, Inc.
+// Copyright 2004 Novell, Inc.
 //
 //
 #if ! BOOTSTRAP_WITH_OLDLIB
@@ -62,9 +62,9 @@ namespace Mono.CSharp {
                                foreach (TypeContainer tc in t.Types)
                                        tc.GenerateDocComment (t);
 
-                       if (t.Enums != null)
-                               foreach (Enum en in t.Enums)
-                                       en.GenerateDocComment (t);
+                       if (t.Delegates != null)
+                               foreach (Delegate de in t.Delegates)
+                                       de.GenerateDocComment (t);
 
                        if (t.Constants != null)
                                foreach (Const c in t.Constants)
@@ -87,7 +87,7 @@ namespace Mono.CSharp {
                                        p.GenerateDocComment (t);
 
                        if (t.Methods != null)
-                               foreach (Method m in t.Methods)
+                               foreach (MethodOrOperator m in t.Methods)
                                        m.GenerateDocComment (t);
 
                        if (t.Operators != null)
@@ -96,7 +96,7 @@ namespace Mono.CSharp {
                }
 
                // MemberCore
-               private static readonly string lineHead =
+               private static readonly string line_head =
                        Environment.NewLine + "            ";
 
                private static XmlNode GetDocCommentNode (MemberCore mc,
@@ -125,10 +125,10 @@ namespace Mono.CSharp {
                                        if (s.Length > 0)
                                                split [j++] = s;
                                }
-                               el.InnerXml = lineHead + String.Join (
-                                       lineHead, split, 0, j);
+                               el.InnerXml = line_head + String.Join (
+                                       line_head, split, 0, j);
                                return el;
-                       } catch (XmlException ex) {
+                       } catch (Exception ex) {
                                Report.Warning (1570, 1, mc.Location, "XML comment on `{0}' has non-well-formed XML ({1})", name, ex.Message);
                                XmlComment com = doc.CreateComment (String.Format ("FIXME: Invalid documentation markup was found for member {0}", name));
                                return com;
@@ -164,16 +164,16 @@ namespace Mono.CSharp {
                                        }
 
                                        // FIXME: it could be done with XmlReader
-                                       DeclSpace dsTarget = mc as DeclSpace;
-                                       if (dsTarget == null)
-                                               dsTarget = ds;
+                                       DeclSpace ds_target = mc as DeclSpace;
+                                       if (ds_target == null)
+                                               ds_target = ds;
 
                                        foreach (XmlElement see in n.SelectNodes (".//see"))
-                                               HandleSee (mc, dsTarget, see);
+                                               HandleSee (mc, ds_target, see);
                                        foreach (XmlElement seealso in n.SelectNodes (".//seealso"))
-                                               HandleSeeAlso (mc, dsTarget, seealso);
+                                               HandleSeeAlso (mc, ds_target, seealso);
                                        foreach (XmlElement see in n.SelectNodes (".//exception"))
-                                               HandleException (mc, dsTarget, see);
+                                               HandleException (mc, ds_target, see);
                                }
 
                                n.WriteTo (RootContext.Documentation.XmlCommentOutput);
@@ -192,18 +192,18 @@ namespace Mono.CSharp {
                //
                private static bool HandleInclude (MemberCore mc, XmlElement el)
                {
-                       bool keepIncludeNode = false;
+                       bool keep_include_node = false;
                        string file = el.GetAttribute ("file");
                        string path = el.GetAttribute ("path");
                        if (file == "") {
                                Report.Warning (1590, 1, mc.Location, "Invalid XML `include' element. Missing `file' attribute");
                                el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
-                               keepIncludeNode = true;
+                               keep_include_node = true;
                        }
                        else if (path.Length == 0) {
                                Report.Warning (1590, 1, mc.Location, "Invalid XML `include' element. Missing `path' attribute");
                                el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
-                               keepIncludeNode = true;
+                               keep_include_node = true;
                        }
                        else {
                                XmlDocument doc = RootContext.Documentation.StoredDocuments [file] as XmlDocument;
@@ -223,7 +223,7 @@ namespace Mono.CSharp {
                                                if (nl.Count == 0) {
                                                        el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" No matching elements were found for the include tag embedded here. "), el);
                                        
-                                                       keepIncludeNode = true;
+                                                       keep_include_node = true;
                                                }
                                                foreach (XmlNode n in nl)
                                                        el.ParentNode.InsertBefore (el.OwnerDocument.ImportNode (n, true), el);
@@ -233,7 +233,7 @@ namespace Mono.CSharp {
                                        }
                                }
                        }
-                       return keepIncludeNode;
+                       return keep_include_node;
                }
 
                //
@@ -272,17 +272,17 @@ namespace Mono.CSharp {
                //
                private static Type FindDocumentedType (MemberCore mc, string name, DeclSpace ds, string cref)
                {
-                       bool isArray = false;
+                       bool is_array = false;
                        string identifier = name;
                        if (name [name.Length - 1] == ']') {
                                string tmp = name.Substring (0, name.Length - 1).Trim (wsChars);
                                if (tmp [tmp.Length - 1] == '[') {
                                        identifier = tmp.Substring (0, tmp.Length - 1).Trim (wsChars);
-                                       isArray = true;
+                                       is_array = true;
                                }
                        }
                        Type t = FindDocumentedTypeNonArray (mc, identifier, ds, cref);
-                       if (t != null && isArray)
+                       if (t != null && is_array)
                                t = Array.CreateInstance (t, 0).GetType ();
                        return t;
                }
@@ -292,39 +292,39 @@ namespace Mono.CSharp {
                {
                        switch (identifier) {
                        case "int":
-                               return typeof (int);
+                               return TypeManager.int32_type;
                        case "uint":
-                               return typeof (uint);
+                               return TypeManager.uint32_type;
                        case "short":
-                               return typeof (short);
+                               return TypeManager.short_type;;
                        case "ushort":
-                               return typeof (ushort);
+                               return TypeManager.ushort_type;
                        case "long":
-                               return typeof (long);
+                               return TypeManager.int64_type;
                        case "ulong":
-                               return typeof (ulong);
+                               return TypeManager.uint64_type;;
                        case "float":
-                               return typeof (float);
+                               return TypeManager.float_type;;
                        case "double":
-                               return typeof (double);
+                               return TypeManager.double_type;
                        case "char":
-                               return typeof (char);
+                               return TypeManager.char_type;;
                        case "decimal":
-                               return typeof (decimal);
+                               return TypeManager.decimal_type;;
                        case "byte":
-                               return typeof (byte);
+                               return TypeManager.byte_type;;
                        case "sbyte":
-                               return typeof (sbyte);
+                               return TypeManager.sbyte_type;;
                        case "object":
-                               return typeof (object);
+                               return TypeManager.object_type;;
                        case "bool":
-                               return typeof (bool);
+                               return TypeManager.bool_type;;
                        case "string":
-                               return typeof (string);
+                               return TypeManager.string_type;;
                        case "void":
-                               return typeof (void);
+                               return TypeManager.void_type;;
                        }
-                       FullNamedExpression e = ds.LookupType (identifier, mc.Location, false);
+                       FullNamedExpression e = ds.LookupNamespaceOrType (identifier, mc.Location, false);
                        if (e != null) {
                                if (!(e is TypeExpr))
                                        return null;
@@ -347,12 +347,12 @@ namespace Mono.CSharp {
                        new MemberInfo [0];
 
                private static MemberInfo [] FindMethodBase (Type type,
-                       BindingFlags bindingFlags, MethodSignature signature)
+                       BindingFlags binding_flags, MethodSignature signature)
                {
                        MemberList ml = TypeManager.FindMembers (
                                type,
                                MemberTypes.Constructor | MemberTypes.Method | MemberTypes.Property | MemberTypes.Custom,
-                               bindingFlags,
+                               binding_flags,
                                MethodSignature.method_signature_filter,
                                signature);
                        if (ml == null)
@@ -363,11 +363,11 @@ namespace Mono.CSharp {
 
                static bool IsOverride (PropertyInfo deriv_prop, PropertyInfo base_prop)
                {
-                       if (!Invocation.IsAncestralType (base_prop.DeclaringType, deriv_prop.DeclaringType))
+                       if (!MethodGroupExpr.IsAncestralType (base_prop.DeclaringType, deriv_prop.DeclaringType))
                                return false;
 
-                       Type [] deriv_pd = TypeManager.GetArgumentTypes (deriv_prop);
-                       Type [] base_pd = TypeManager.GetArgumentTypes (base_prop);
+                       Type [] deriv_pd = TypeManager.GetParameterData (deriv_prop).Types;
+                       Type [] base_pd = TypeManager.GetParameterData (base_prop).Types;
                
                        if (deriv_pd.Length != base_pd.Length)
                                return false;
@@ -402,7 +402,7 @@ namespace Mono.CSharp {
                                                        continue;
                                                MethodBase my = ml [j] as MethodBase;
                                                if (mx != null && my != null &&
-                                                       Invocation.IsOverride (my, mx)) {
+                                                       MethodGroupExpr.IsOverride (my, mx)) {
                                                        overriden = true;
                                                        break;
                                                }
@@ -431,17 +431,17 @@ namespace Mono.CSharp {
                        public readonly MemberInfo Member;
                        public readonly Type Type;
 
-                       public FoundMember (bool regardlessOfThisValueItsEmpty)
+                       public FoundMember (bool regardless_of_this_value_its_empty)
                        {
                                IsEmpty = true;
                                Member = null;
                                Type = null;
                        }
 
-                       public FoundMember (Type foundType, MemberInfo member)
+                       public FoundMember (Type found_type, MemberInfo member)
                        {
                                IsEmpty = false;
-                               Type = foundType;
+                               Type = found_type;
                                Member = member;
                        }
                }
@@ -451,127 +451,88 @@ namespace Mono.CSharp {
                // (by "see" or "seealso" elements).
                //
                private static FoundMember FindDocumentedMember (MemberCore mc,
-                       Type type, string memberName, Type [] paramList, 
-                       DeclSpace ds, out int warningType, string cref,
-                       bool warn419, string nameForError)
+                       Type type, string member_name, Type [] param_list, 
+                       DeclSpace ds, out int warning_type, string cref,
+                       bool warn419, string name_for_error)
                {
                        for (; type != null; type = type.DeclaringType) {
                                MemberInfo mi = FindDocumentedMemberNoNest (
-                                       mc, type, memberName, paramList, ds,
-                                       out warningType, cref, warn419,
-                                       nameForError);
+                                       mc, type, member_name, param_list, ds,
+                                       out warning_type, cref, warn419,
+                                       name_for_error);
                                if (mi != null)
                                        return new FoundMember (type, mi);
                        }
-                       warningType = 0;
+                       warning_type = 0;
                        return FoundMember.Empty;
                }
 
                private static MemberInfo FindDocumentedMemberNoNest (
-                       MemberCore mc, Type type, string memberName,
-                       Type [] paramList, DeclSpace ds, out int warningType, 
-                       string cref, bool warn419, string nameForError)
+                       MemberCore mc, Type type, string member_name,
+                       Type [] param_list, DeclSpace ds, out int warning_type, 
+                       string cref, bool warn419, string name_for_error)
                {
-                       warningType = 0;
+                       warning_type = 0;
                        MemberInfo [] mis;
 
-                       if (paramList == null) {
+                       if (param_list == null) {
                                // search for fields/events etc.
                                mis = TypeManager.MemberLookup (type, null,
                                        type, MemberTypes.All,
                                        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
-                                       memberName, null);
+                                       member_name, null);
                                mis = FilterOverridenMembersOut (mis);
                                if (mis == null || mis.Length == 0)
                                        return null;
                                if (warn419 && IsAmbiguous (mis))
-                                       Report419 (mc, nameForError, mis);
+                                       Report419 (mc, name_for_error, mis);
                                return mis [0];
                        }
 
-                       MethodSignature msig = new MethodSignature (memberName, null, paramList);
+                       MethodSignature msig = new MethodSignature (member_name, null, param_list);
                        mis = FindMethodBase (type, 
                                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
                                msig);
 
                        if (warn419 && mis.Length > 0) {
                                if (IsAmbiguous (mis))
-                                       Report419 (mc, nameForError, mis);
+                                       Report419 (mc, name_for_error, mis);
                                return mis [0];
                        }
 
                        // search for operators (whose parameters exactly
                        // matches with the list) and possibly report CS1581.
                        string oper = null;
-                       string returnTypeName = null;
-                       if (memberName.StartsWith ("implicit operator ")) {
-                               oper = "op_Implicit";
-                               returnTypeName = memberName.Substring (18).Trim (wsChars);
+                       string return_type_name = null;
+                       if (member_name.StartsWith ("implicit operator ")) {
+                               Operator.GetMetadataName (Operator.OpType.Implicit);
+                               return_type_name = member_name.Substring (18).Trim (wsChars);
                        }
-                       else if (memberName.StartsWith ("explicit operator ")) {
-                               oper = "op_Explicit";
-                               returnTypeName = memberName.Substring (18).Trim (wsChars);
+                       else if (member_name.StartsWith ("explicit operator ")) {
+                               oper = Operator.GetMetadataName (Operator.OpType.Explicit);
+                               return_type_name = member_name.Substring (18).Trim (wsChars);
                        }
-                       else if (memberName.StartsWith ("operator ")) {
-                               oper = memberName.Substring (9).Trim (wsChars);
+                       else if (member_name.StartsWith ("operator ")) {
+                               oper = member_name.Substring (9).Trim (wsChars);
                                switch (oper) {
                                // either unary or binary
                                case "+":
-                                       oper = paramList.Length == 2 ?
-                                               Binary.oper_names [(int) Binary.Operator.Addition] :
-                                               Unary.oper_names [(int) Unary.Operator.UnaryPlus];
+                                       oper = param_list.Length == 2 ?
+                                               Operator.GetMetadataName (Operator.OpType.Addition) :
+                                               Operator.GetMetadataName (Operator.OpType.UnaryPlus);
                                        break;
                                case "-":
-                                       oper = paramList.Length == 2 ?
-                                               Binary.oper_names [(int) Binary.Operator.Subtraction] :
-                                               Unary.oper_names [(int) Unary.Operator.UnaryNegation];
+                                       oper = param_list.Length == 2 ?
+                                               Operator.GetMetadataName (Operator.OpType.Subtraction) :
+                                               Operator.GetMetadataName (Operator.OpType.UnaryNegation);
                                        break;
-                               // unary
-                               case "!":
-                                       oper = Unary.oper_names [(int) Unary.Operator.LogicalNot]; break;
-                               case "~":
-                                       oper = Unary.oper_names [(int) Unary.Operator.OnesComplement]; break;
-                                       
-                               case "++":
-                                       oper = "op_Increment"; break;
-                               case "--":
-                                       oper = "op_Decrement"; break;
-                               case "true":
-                                       oper = "op_True"; break;
-                               case "false":
-                                       oper = "op_False"; break;
-                               // binary
-                               case "*":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Multiply]; break;
-                               case "/":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Division]; break;
-                               case "%":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Modulus]; break;
-                               case "&":
-                                       oper = Binary.oper_names [(int) Binary.Operator.BitwiseAnd]; break;
-                               case "|":
-                                       oper = Binary.oper_names [(int) Binary.Operator.BitwiseOr]; break;
-                               case "^":
-                                       oper = Binary.oper_names [(int) Binary.Operator.ExclusiveOr]; break;
-                               case "<<":
-                                       oper = Binary.oper_names [(int) Binary.Operator.LeftShift]; break;
-                               case ">>":
-                                       oper = Binary.oper_names [(int) Binary.Operator.RightShift]; break;
-                               case "==":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Equality]; break;
-                               case "!=":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Inequality]; break;
-                               case "<":
-                                       oper = Binary.oper_names [(int) Binary.Operator.LessThan]; break;
-                               case ">":
-                                       oper = Binary.oper_names [(int) Binary.Operator.GreaterThan]; break;
-                               case "<=":
-                                       oper = Binary.oper_names [(int) Binary.Operator.LessThanOrEqual]; break;
-                               case ">=":
-                                       oper = Binary.oper_names [(int) Binary.Operator.GreaterThanOrEqual]; break;
                                default:
-                                       warningType = 1584;
-                                       Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", paramList.Length == 2 ? "binary" : "unary");
+                                       oper = Operator.GetMetadataName (oper);
+                                       if (oper != null)
+                                               break;
+
+                                       warning_type = 1584;
+                                       Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", param_list.Length == 2 ? "binary" : "unary");
                                        Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'",
                                                mc.GetSignatureForError (), cref);
                                        return null;
@@ -579,7 +540,7 @@ namespace Mono.CSharp {
                        }
                        // here we still don't consider return type (to
                        // detect CS1581 or CS1002+CS1584).
-                       msig = new MethodSignature (oper, null, paramList);
+                       msig = new MethodSignature (oper, null, param_list);
 
                        mis = FindMethodBase (type, 
                                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
@@ -592,10 +553,10 @@ namespace Mono.CSharp {
                                mi is PropertyInfo ?
                                ((PropertyInfo) mi).PropertyType :
                                null;
-                       if (returnTypeName != null) {
-                               Type returnType = FindDocumentedType (mc, returnTypeName, ds, cref);
+                       if (return_type_name != null) {
+                               Type returnType = FindDocumentedType (mc, return_type_name, ds, cref);
                                if (returnType == null || returnType != expected) {
-                                       warningType = 1581;
+                                       warning_type = 1581;
                                        Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute `{0}'", cref);
                                        return null;
                                }
@@ -635,23 +596,30 @@ namespace Mono.CSharp {
                        string name; // method invokation "(...)" are removed
                        string parameters; // method parameter list
 
-                       // strip 'T:' 'M:' 'F:' 'P:' 'E:' etc.
-                       // Here, MS ignores its member kind. No idea why.
+                       // When it found '?:' ('T:' 'M:' 'F:' 'P:' 'E:' etc.),
+                       // MS ignores not only its member kind, but also
+                       // the entire syntax correctness. Nor it also does
+                       // type fullname resolution i.e. "T:List(int)" is kept
+                       // as T:List(int), not
+                       // T:System.Collections.Generic.List&lt;System.Int32&gt;
                        if (cref.Length > 2 && cref [1] == ':')
-                               signature = cref.Substring (2).Trim (wsChars);
+                               return;
                        else
                                signature = cref;
 
-                       int parensPos = signature.IndexOf ('(');
-                       int bracePos = parensPos >= 0 ? -1 :
+                       // Also note that without "T:" any generic type 
+                       // indication fails.
+
+                       int parens_pos = signature.IndexOf ('(');
+                       int brace_pos = parens_pos >= 0 ? -1 :
                                signature.IndexOf ('[');
-                       if (parensPos > 0 && signature [signature.Length - 1] == ')') {
-                               name = signature.Substring (0, parensPos).Trim (wsChars);
-                               parameters = signature.Substring (parensPos + 1, signature.Length - parensPos - 2).Trim (wsChars);
+                       if (parens_pos > 0 && signature [signature.Length - 1] == ')') {
+                               name = signature.Substring (0, parens_pos).Trim (wsChars);
+                               parameters = signature.Substring (parens_pos + 1, signature.Length - parens_pos - 2).Trim (wsChars);
                        }
-                       else if (bracePos > 0 && signature [signature.Length - 1] == ']') {
-                               name = signature.Substring (0, bracePos).Trim (wsChars);
-                               parameters = signature.Substring (bracePos + 1, signature.Length - bracePos - 2).Trim (wsChars);
+                       else if (brace_pos > 0 && signature [signature.Length - 1] == ']') {
+                               name = signature.Substring (0, brace_pos).Trim (wsChars);
+                               parameters = signature.Substring (brace_pos + 1, signature.Length - brace_pos - 2).Trim (wsChars);
                        }
                        else {
                                name = signature;
@@ -664,9 +632,9 @@ namespace Mono.CSharp {
                        // Check if identifier is valid.
                        // This check is not necessary to mark as error, but
                        // csc specially reports CS1584 for wrong identifiers.
-                       string [] nameElems = identifier.Split ('.');
-                       for (int i = 0; i < nameElems.Length; i++) {
-                               string nameElem = GetBodyIdentifierFromName (nameElems [i]);
+                       string [] name_elems = identifier.Split ('.');
+                       for (int i = 0; i < name_elems.Length; i++) {
+                               string nameElem = GetBodyIdentifierFromName (name_elems [i]);
                                if (i > 0)
                                        Normalize (mc, ref nameElem);
                                if (!Tokenizer.IsValidIdentifier (nameElem)
@@ -679,35 +647,35 @@ namespace Mono.CSharp {
                        }
 
                        // check if parameters are valid
-                       Type [] parameterTypes;
+                       Type [] parameter_types;
                        if (parameters == null)
-                               parameterTypes = null;
+                               parameter_types = null;
                        else if (parameters.Length == 0)
-                               parameterTypes = Type.EmptyTypes;
+                               parameter_types = Type.EmptyTypes;
                        else {
-                               string [] paramList = parameters.Split (',');
+                               string [] param_list = parameters.Split (',');
                                ArrayList plist = new ArrayList ();
-                               for (int i = 0; i < paramList.Length; i++) {
-                                       string paramTypeName = paramList [i].Trim (wsChars);
-                                       Normalize (mc, ref paramTypeName);
-                                       Type paramType = FindDocumentedType (mc, paramTypeName, ds, cref);
-                                       if (paramType == null) {
+                               for (int i = 0; i < param_list.Length; i++) {
+                                       string param_type_name = param_list [i].Trim (wsChars);
+                                       Normalize (mc, ref param_type_name);
+                                       Type param_type = FindDocumentedType (mc, param_type_name, ds, cref);
+                                       if (param_type == null) {
                                                Report.Warning (1580, 1, mc.Location, "Invalid type for parameter `{0}' in XML comment cref attribute `{1}'",
                                                        (i + 1).ToString (), cref);
                                                return;
                                        }
-                                       plist.Add (paramType);
+                                       plist.Add (param_type);
                                }
-                               parameterTypes = plist.ToArray (typeof (Type)) as Type [];
+                               parameter_types = plist.ToArray (typeof (Type)) as Type [];
                        }
 
                        Type type = FindDocumentedType (mc, name, ds, cref);
                        if (type != null
                                // delegate must not be referenced with args
-                               && (!type.IsSubclassOf (typeof (System.Delegate))
-                               || parameterTypes == null)) {
+                               && (!TypeManager.IsDelegateType (type)
+                               || parameter_types == null)) {
                                string result = GetSignatureForDoc (type)
-                                       + (bracePos < 0 ? String.Empty : signature.Substring (bracePos));
+                                       + (brace_pos < 0 ? String.Empty : signature.Substring (brace_pos));
                                xref.SetAttribute ("cref", "T:" + result);
                                return; // a type
                        }
@@ -715,13 +683,13 @@ namespace Mono.CSharp {
                        int period = name.LastIndexOf ('.');
                        if (period > 0) {
                                string typeName = name.Substring (0, period);
-                               string memberName = name.Substring (period + 1);
-                               Normalize (mc, ref memberName);
+                               string member_name = name.Substring (period + 1);
+                               Normalize (mc, ref member_name);
                                type = FindDocumentedType (mc, typeName, ds, cref);
-                               int warnResult;
+                               int warn_result;
                                if (type != null) {
-                                       FoundMember fm = FindDocumentedMember (mc, type, memberName, parameterTypes, ds, out warnResult, cref, true, name);
-                                       if (warnResult > 0)
+                                       FoundMember fm = FindDocumentedMember (mc, type, member_name, parameter_types, ds, out warn_result, cref, true, name);
+                                       if (warn_result > 0)
                                                return;
                                        if (!fm.IsEmpty) {
                                                MemberInfo mi = fm.Member;
@@ -729,15 +697,15 @@ namespace Mono.CSharp {
                                                // to get its name, since mi
                                                // could be from DeclaringType
                                                // for nested types.
-                                               xref.SetAttribute ("cref", GetMemberDocHead (mi.MemberType) + GetSignatureForDoc (fm.Type) + "." + memberName + GetParametersFormatted (mi));
+                                               xref.SetAttribute ("cref", GetMemberDocHead (mi.MemberType) + GetSignatureForDoc (fm.Type) + "." + member_name + GetParametersFormatted (mi));
                                                return; // a member of a type
                                        }
                                }
                        }
                        else {
-                               int warnResult;
-                               FoundMember fm = FindDocumentedMember (mc, ds.TypeBuilder, name, parameterTypes, ds, out warnResult, cref, true, name);
-                               if (warnResult > 0)
+                               int warn_result;
+                               FoundMember fm = FindDocumentedMember (mc, ds.TypeBuilder, name, parameter_types, ds, out warn_result, cref, true, name);
+                               if (warn_result > 0)
                                        return;
                                if (!fm.IsEmpty) {
                                        MemberInfo mi = fm.Member;
@@ -753,7 +721,7 @@ namespace Mono.CSharp {
                        // It still might be part of namespace name.
                        Namespace ns = ds.NamespaceEntry.NS.GetNamespace (name, false);
                        if (ns != null) {
-                               xref.SetAttribute ("cref", "N:" + ns.FullName);
+                               xref.SetAttribute ("cref", "N:" + ns.GetSignatureForError ());
                                return; // a namespace
                        }
                        if (RootNamespace.Global.IsNamespace (name)) {
@@ -770,30 +738,30 @@ namespace Mono.CSharp {
                static string GetParametersFormatted (MemberInfo mi)
                {
                        MethodBase mb = mi as MethodBase;
-                       bool isSetter = false;
+                       bool is_setter = false;
                        PropertyInfo pi = mi as PropertyInfo;
                        if (pi != null) {
                                mb = pi.GetGetMethod ();
                                if (mb == null) {
-                                       isSetter = true;
+                                       is_setter = true;
                                        mb = pi.GetSetMethod ();
                                }
                        }
                        if (mb == null)
                                return String.Empty;
 
-                       ParameterData parameters = TypeManager.GetParameterData (mb);
+                       AParametersCollection parameters = TypeManager.GetParameterData (mb);
                        if (parameters == null || parameters.Count == 0)
                                return String.Empty;
 
                        StringBuilder sb = new StringBuilder ();
                        sb.Append ('(');
                        for (int i = 0; i < parameters.Count; i++) {
-                               if (isSetter && i + 1 == parameters.Count)
+                               if (is_setter && i + 1 == parameters.Count)
                                        break; // skip "value".
                                if (i > 0)
                                        sb.Append (',');
-                               Type t = parameters.ParameterType (i);
+                               Type t = parameters.Types [i];
                                sb.Append (GetSignatureForDoc (t));
                        }
                        sb.Append (')');
@@ -814,11 +782,11 @@ namespace Mono.CSharp {
                        return identifier;
                }
 
-               static void Report419 (MemberCore mc, string memberName, MemberInfo [] mis)
+               static void Report419 (MemberCore mc, string member_name, MemberInfo [] mis)
                {
                        Report.Warning (419, 3, mc.Location, 
                                "Ambiguous reference in cref attribute `{0}'. Assuming `{1}' but other overloads including `{2}' have also matched",
-                               memberName,
+                               member_name,
                                TypeManager.GetFullNameSignature (mis [0]),
                                TypeManager.GetFullNameSignature (mis [1]));
                }
@@ -852,15 +820,18 @@ namespace Mono.CSharp {
                // Returns a string that represents the signature for this 
                // member which should be used in XML documentation.
                //
-               public static string GetMethodDocCommentName (MethodCore mc, DeclSpace ds)
+               public static string GetMethodDocCommentName (MemberCore mc, Parameters parameters, DeclSpace ds)
                {
-                       Parameter [] plist = mc.Parameters.FixedParameters;
+                       IParameterData [] plist = parameters.FixedParameters;
                        string paramSpec = String.Empty;
                        if (plist != null) {
                                StringBuilder psb = new StringBuilder ();
+                               int i = 0;
                                foreach (Parameter p in plist) {
                                        psb.Append (psb.Length != 0 ? "," : "(");
-                                       psb.Append (GetSignatureForDoc (p.ExternalType ()));
+                                       psb.Append (GetSignatureForDoc (parameters.Types [i++]));
+                                       if ((p.ModFlags & Parameter.Modifier.ISBYREF) != 0)
+                                               psb.Append ('@');
                                }
                                paramSpec = psb.ToString ();
                        }
@@ -869,6 +840,10 @@ namespace Mono.CSharp {
                                paramSpec += ")";
 
                        string name = mc is Constructor ? "#ctor" : mc.Name;
+#if GMCS_SOURCE                                                    
+                       if (mc.MemberName.IsGeneric)
+                               name += "``" + mc.MemberName.CountTypeArguments;
+#endif
                        string suffix = String.Empty;
                        Operator op = mc as Operator;
                        if (op != null) {
@@ -884,9 +859,26 @@ namespace Mono.CSharp {
 
                static string GetSignatureForDoc (Type type)
                {
-                       return TypeManager.IsGenericParameter (type) ?
-                               "`" + TypeManager.GenericParameterPosition (type) :
-                               type.FullName.Replace ("+", ".").Replace ('&', '@');
+#if GMCS_SOURCE
+                       if (TypeManager.IsGenericParameter (type))
+                               return (type.DeclaringMethod != null ? "``" : "`") + TypeManager.GenericParameterPosition (type);
+
+                       if (TypeManager.IsGenericType (type)) {
+                               string g = type.Namespace;
+                               if (g != null && g.Length > 0)
+                                       g += '.';
+                               int idx = type.Name.LastIndexOf ('`');
+                               g += (idx < 0 ? type.Name : type.Name.Substring (0, idx)) + '{';
+                               int argpos = 0;
+                               foreach (Type t in type.GetGenericArguments ())
+                                       g += (argpos++ > 0 ? "," : String.Empty) + GetSignatureForDoc (t);
+                               g += '}';
+                               return g;
+                       }
+#endif
+
+                       string name = type.FullName != null ? type.FullName : type.Name;
+                       return name.Replace ("+", ".").Replace ('&', '@');
                }
 
                //
@@ -901,11 +893,10 @@ namespace Mono.CSharp {
                {
                        Hashtable paramTags = new Hashtable ();
                        foreach (XmlElement pelem in el.SelectNodes ("param")) {
-                               int i;
                                string xname = pelem.GetAttribute ("name");
                                if (xname.Length == 0)
                                        continue; // really? but MS looks doing so
-                               if (xname != "" && mc.Parameters.GetParameterByName (xname, out i) == null)
+                               if (xname != "" && mc.Parameters.GetParameterIndexByName (xname) < 0)
                                        Report.Warning (1572, 2, mc.Location, "XML comment on `{0}' has a param tag for `{1}', but there is no parameter by that name",
                                                mc.GetSignatureForError (), xname);
                                else if (paramTags [xname] != null)
@@ -913,7 +904,7 @@ namespace Mono.CSharp {
                                                mc.GetSignatureForError (), xname);
                                paramTags [xname] = xname;
                        }
-                       Parameter [] plist = mc.Parameters.FixedParameters;
+                       IParameterData [] plist = mc.Parameters.FixedParameters;
                        foreach (Parameter p in plist) {
                                if (paramTags.Count > 0 && paramTags [p.Name] == null)
                                        Report.Warning (1573, 4, mc.Location, "Parameter `{0}' has no matching param tag in the XML comment for `{1}'",
@@ -1026,9 +1017,6 @@ namespace Mono.CSharp {
                public void GenerateDocComment ()
                {
                        TypeContainer root = RootContext.ToplevelTypes;
-                       if (root.Interfaces != null)
-                               foreach (Interface i in root.Interfaces) 
-                                       DocUtil.GenerateTypeDocComment (i, null);
 
                        if (root.Types != null)
                                foreach (TypeContainer tc in root.Types)
@@ -1037,11 +1025,6 @@ namespace Mono.CSharp {
                        if (root.Delegates != null)
                                foreach (Delegate d in root.Delegates) 
                                        DocUtil.GenerateDocComment (d, null);
-
-                       if (root.Enums != null)
-                               foreach (Enum e in root.Enums)
-                                       e.GenerateDocComment (null);
-
                }
        }
 }