Enable await expressions to work with dynamic binder
[mono.git] / mcs / mcs / doc.cs
index 76f513ad67c576a76f1a3d61e860804de4937b7c..769154d6915190f38f57dae2f6a5716424273c16 100644 (file)
@@ -150,6 +150,10 @@ namespace Mono.CSharp
                                        HandleSeeAlso (mc, ds_target, seealso);
                                foreach (XmlElement see in n.SelectNodes (".//exception"))
                                        HandleException (mc, ds_target, see);
+                               foreach (XmlElement node in n.SelectNodes (".//typeparam"))
+                                       HandleTypeParam (mc, node);
+                               foreach (XmlElement node in n.SelectNodes (".//typeparamref"))
+                                       HandleTypeParamRef (mc, node);
                        }
 
                        n.WriteTo (XmlCommentOutput);
@@ -229,15 +233,64 @@ namespace Mono.CSharp
                        HandleXrefCommon (mc, ds, seealso);
                }
 
+               //
+               // Handles <typeparam /> node
+               //
+               void HandleTypeParam (MemberCore mc, XmlElement node)
+               {
+                       if (!node.HasAttribute ("name"))
+                               return;
+
+                       string tp_name = node.GetAttribute ("name");
+                       if (mc.CurrentTypeParameters != null) {
+                               foreach (var tp in mc.CurrentTypeParameters) {
+                                       if (tp.Name == tp_name)
+                                               return;
+                               }
+                       }
+                       
+                       // TODO: CS1710, CS1712
+                       
+                       mc.Compiler.Report.Warning (1711, 2, mc.Location,
+                               "XML comment on `{0}' has a typeparam name `{1}' but there is no type parameter by that name",
+                               mc.GetSignatureForError (), tp_name);
+               }
+
+               //
+               // Handles <typeparamref /> node
+               //
+               void HandleTypeParamRef (MemberCore mc, XmlElement node)
+               {
+                       if (!node.HasAttribute ("name"))
+                               return;
+
+                       string tp_name = node.GetAttribute ("name");
+                       var member = mc;
+                       do {
+                               if (member.CurrentTypeParameters != null) {
+                                       foreach (var tp in member.CurrentTypeParameters) {
+                                               if (tp.Name == tp_name)
+                                                       return;
+                                       }
+                               }
+
+                               member = member.Parent;
+                       } while (member != null);
+
+                       mc.Compiler.Report.Warning (1735, 2, mc.Location,
+                               "XML comment on `{0}' has a typeparamref name `{1}' that could not be resolved",
+                               mc.GetSignatureForError (), tp_name);
+               }
+
                FullNamedExpression ResolveMemberName (IMemberContext context, MemberName mn)
                {
                        if (mn.Left == null)
-                               return context.LookupNamespaceOrType (mn.Name, mn.Arity, Location.Null, /*ignore_cs0104=*/ false);
+                               return context.LookupNamespaceOrType (mn.Name, mn.Arity, LookupMode.Probing, Location.Null);
 
                        var left = ResolveMemberName (context, mn.Left);
                        var ns = left as Namespace;
                        if (ns != null)
-                               return ns.Lookup (context, mn.Name, mn.Arity, Location.Null);
+                               return ns.LookupTypeOrNamespace (context, mn.Name, mn.Arity, LookupMode.Probing, Location.Null);
 
                        TypeExpr texpr = left as TypeExpr;
                        if (texpr != null) {
@@ -320,7 +373,7 @@ namespace Mono.CSharp
                                                if (fne != null) {
                                                        var ns = fne as Namespace;
                                                        if (ns != null) {
-                                                               fne = ns.Lookup (mc, ParsedName.Name, ParsedName.Arity, Location.Null);
+                                                               fne = ns.LookupTypeOrNamespace (mc, ParsedName.Name, ParsedName.Arity, LookupMode.Probing, Location.Null);
                                                                if (fne != null) {
                                                                        member = fne.Type;
                                                                }
@@ -345,9 +398,11 @@ namespace Mono.CSharp
                                }
 
                                if (ParsedParameters != null) {
+                                       var old_printer = mc.Module.Compiler.Report.SetPrinter (new NullReportPrinter ());
                                        foreach (var pp in ParsedParameters) {
                                                pp.Resolve (mc);
                                        }
+                                       mc.Module.Compiler.Report.SetPrinter (old_printer);
                                }
 
                                if (type != null) {
@@ -563,6 +618,7 @@ namespace Mono.CSharp
        {
                public readonly Parameter.Modifier Modifier;
                public FullNamedExpression Type;
+               TypeSpec type;
 
                public DocumentationParameter (Parameter.Modifier modifier, FullNamedExpression type)
                        : this (type)
@@ -577,13 +633,13 @@ namespace Mono.CSharp
 
                public TypeSpec TypeSpec {
                        get {
-                               return Type == null ? null : Type.Type;
+                               return type;
                        }
                }
 
                public void Resolve (IMemberContext context)
                {
-                       Type = Type.ResolveAsTypeTerminal (context, true);
+                       type = Type.ResolveAsType (context);
                }
        }
 }