Merge pull request #1898 from alexanderkyte/debugger_variable_reflection
[mono.git] / mcs / class / corlib / System.Reflection.Emit / TypeBuilder.cs
index 5621065d8039a5fe20b1aa7c39892a419624a047..edf6d58852807e250a372202a96240db1ef8aa41 100644 (file)
@@ -353,7 +353,7 @@ namespace System.Reflection.Emit
                                        }
                                }
                                if (binder == null)
-                                       binder = Binder.DefaultBinder;
+                                       binder = DefaultBinder;
                                return (ConstructorInfo) binder.SelectMethod (bindingAttr, match,
                                                                                                                          types, modifiers);
                        }
@@ -914,6 +914,7 @@ namespace System.Reflection.Emit
                /* Needed to keep signature compatibility with MS.NET */
                public override EventInfo[] GetEvents ()
                {
+                       const BindingFlags DefaultBindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
                        return GetEvents (DefaultBindingFlags);
                }
 
@@ -1192,46 +1193,10 @@ namespace System.Reflection.Emit
                {
                        check_created ();
 
-                       bool ignoreCase = ((bindingAttr & BindingFlags.IgnoreCase) != 0);
-                       MethodInfo[] methods = GetMethodsByName (name, bindingAttr, ignoreCase, this);
-                       MethodInfo found = null;
-                       MethodBase[] match;
-                       int typesLen = (types != null) ? types.Length : 0;
-                       int count = 0;
-                       
-                       foreach (MethodInfo m in methods) {
-                               // Under MS.NET, Standard|HasThis matches Standard...
-                               if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
-                                       continue;
-                               found = m;
-                               count++;
-                       }
-
-                       if (count == 0)
-                               return null;
-                       
-                       if (count == 1 && typesLen == 0) 
-                               return found;
-
-                       match = new MethodBase [count];
-                       if (count == 1)
-                               match [0] = found;
-                       else {
-                               count = 0;
-                               foreach (MethodInfo m in methods) {
-                                       if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
-                                               continue;
-                                       match [count++] = m;
-                               }
-                       }
-                       
-                       if (types == null) 
-                               return (MethodInfo) Binder.FindMostDerivedMatch (match);
+                       if (types == null)
+                               return created.GetMethod (name, bindingAttr);
 
-                       if (binder == null)
-                               binder = Binder.DefaultBinder;
-                       
-                       return (MethodInfo)binder.SelectMethod (bindingAttr, match, types, modifiers);
+                       return created.GetMethod (name, bindingAttr, binder, callConvention, types, modifiers);
                }
 
                public override Type GetNestedType (string name, BindingFlags bindingAttr)
@@ -1899,19 +1864,6 @@ namespace System.Reflection.Emit
                                return res;
                }
 
-               internal TypeCode GetTypeCodeInternal () {
-                       if (parent == pmodule.assemblyb.corlib_enum_type) {
-                               for (int i = 0; i < num_fields; ++i) {
-                                       FieldBuilder f = fields [i];
-                                       if (!f.IsStatic)
-                                               return Type.GetTypeCode (f.FieldType);
-                               }
-                               throw new InvalidOperationException ("Enum basetype field not defined");
-                       } else {
-                               return Type.GetTypeCodeInternal (this);
-                       }
-               }
-
 
                void _TypeBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
                {