* typemanager.cs: Property.GetGetMethod() does not return the method if it
[mono.git] / mcs / mbas / typemanager.cs
index e122ffb2d9cb4c78510b2f3021ff6ee0eb19f476..17a30e3cf6071461af08c086066253a399376056 100644 (file)
@@ -470,6 +470,7 @@ public class TypeManager {
                public readonly string Namespace;
                public readonly string Name;
                public StandardModule(string _namespace, string name) { Namespace = _namespace; Name = name; }
+               public override string ToString() { return ((Namespace != null && Namespace.Length > 0)?(Namespace + "."):"") + Name; }
        }
 
        private static StandardModule[] standardModules;
@@ -484,7 +485,12 @@ public class TypeManager {
 
                if (standardModules != null)
                        standardModules.CopyTo (n, 0);
-               n [top] = new StandardModule(module.Namespace.Name, module.Name) ;
+               string name = module.Name;
+               int split = name.LastIndexOf('.'); 
+               if (split > 0)
+                       name = name.Substring(split+1);
+               n [top] = new StandardModule(module.Namespace.Name, name); 
+               //Console.WriteLine("Standard Module added:" + module.Name + " [" + n [top] + "]");
                standardModules = n;
        }
 
@@ -493,13 +499,20 @@ public class TypeManager {
        /// 
        private static void AddStandardModule(Type type)
        {
-               int top = standardModules != null ? standardModules.Length : 0;
-               StandardModule [] n = new StandardModule [top + 1];
+           object[] attributes = type.GetCustomAttributes(false);
+           for (int i = 0; i < attributes.Length; i ++) {
+                       if (attributes[i].ToString() == "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute") {
+                               int top = standardModules != null ? standardModules.Length : 0;
+                               StandardModule [] n = new StandardModule [top + 1];
 
-               if (standardModules != null)
-                       standardModules.CopyTo (n, 0);
-               n [top] = new StandardModule(type.Namespace, type.Name) ;
-               standardModules = n;
+                               if (standardModules != null)
+                                       standardModules.CopyTo (n, 0);
+                               n [top] = new StandardModule(type.Namespace, type.Name) ;
+                               standardModules = n;
+
+                               return;
+                       }
+        }
        }
 
        //
@@ -511,8 +524,16 @@ public class TypeManager {
                foreach(string Namespace in namespaces)
                { 
                        for(int i = 0; i < standardModules.Length; i++)
-                               if (standardModules[i].Namespace == Namespace)
-                                       list.Add(LookupType(Namespace + "." + standardModules[i].Name));
+                               if (standardModules[i].Namespace == Namespace) {
+                                       string name = standardModules[i].ToString();
+                                       Type t = LookupType(name);
+                                       if (t == null) {
+                                               System.Console.WriteLine("Could not find standard module '" + name + "'"); 
+                                       }
+                                       else {
+                                               list.Add(t);
+                                       }
+                               }
                }
                return (Type[])list.ToArray(typeof(Type));
        }
@@ -621,8 +642,8 @@ public class TypeManager {
        {
                CaseInsensitiveHashtable namespaces = new CaseInsensitiveHashtable ();
 
-               foreach (Assembly a in assemblies){
-                       foreach (Type t in a.GetTypes ()){
+               foreach (Assembly a in assemblies) {
+                       foreach (Type t in a.GetTypes ()) {
                                string ns = t.Namespace;
 
                                if (namespaces.Contains (ns))
@@ -631,8 +652,8 @@ public class TypeManager {
                        }
                }
 
-               foreach (ModuleBuilder mb in modules){
-                       foreach (Type t in mb.GetTypes ()){
+               foreach (ModuleBuilder mb in modules) {
+                       foreach (Type t in mb.GetTypes ()) {
                                string ns = t.Namespace;
 
                                if (namespaces.Contains (ns))
@@ -640,6 +661,7 @@ public class TypeManager {
                                namespaces [ns] = ns;
                        }
                }
+
                return namespaces;
        }
        
@@ -1488,7 +1510,7 @@ public class TypeManager {
 
                        return (MethodInfo) de.Second;
                } else
-                       return pi.GetSetMethod ();
+                       return pi.GetSetMethod (true);
        }
 
        static public MethodInfo GetPropertySetter (PropertyInfo pi)
@@ -1498,7 +1520,7 @@ public class TypeManager {
 
                        return (MethodInfo) de.First;
                } else
-                       return pi.GetGetMethod ();
+                       return pi.GetGetMethod (true);
        }
 
        /// <summary>
@@ -2130,6 +2152,8 @@ public class TypeManager {
                
                ArrayList method_list = null;
                Type current_type = queried_type;
+               if (queried_type == null)
+                       throw new ArgumentNullException("queried_type");
                bool searching = (original_bf & BindingFlags.DeclaredOnly) == 0;
                bool private_ok;
                bool always_ok_flag = false;
@@ -2191,7 +2215,7 @@ public class TypeManager {
                        closure_queried_type = current_type;
 
                        Timer.StopTimer (TimerType.MemberLookup);
-bf |= BindingFlags.IgnoreCase;
+                       bf |= BindingFlags.IgnoreCase;
                        list = MemberLookup_FindMembers (current_type, mt, bf, name, out used_cache);
 
                        Timer.StartTimer (TimerType.MemberLookup);