Merge pull request #925 from ermshiperete/novell-bug-602934
[mono.git] / mcs / class / corlib / System.Reflection / MonoAssembly.cs
index f15794e354930ba0c3857eca90a68c399e301e3c..fedff328ce7dd41801dbe977817df96c9a7b81fe 100644 (file)
@@ -30,7 +30,10 @@ using System;
 using System.Collections;
 using System.Globalization;
 using System.Runtime.InteropServices;
-
+#if !FULL_AOT_RUNTIME
+using System.Reflection.Emit;
+#endif
+using System.Collections.Generic;
 
 namespace System.Reflection {
 
@@ -49,12 +52,21 @@ namespace System.Reflection {
 #endif
                Type GetType (string name, bool throwOnError, bool ignoreCase)
                {
+                       Type res;
                        if (name == null)
                                throw new ArgumentNullException (name);
                        if (name.Length == 0)
                        throw new ArgumentException ("name", "Name cannot be empty");
 
-                       return InternalGetType (null, name, throwOnError, ignoreCase);
+                       res = InternalGetType (null, name, throwOnError, ignoreCase);
+#if !NET_4_0 && !FULL_AOT_RUNTIME
+                       if (res is TypeBuilder) {
+                               if (throwOnError)
+                                       throw new TypeLoadException (string.Format ("Could not load type '{0}' from assembly '{1}'", name, this));
+                               return null;
+                       }
+#endif
+                       return res;
                }
 
                public
@@ -93,11 +105,11 @@ namespace System.Reflection {
                        Module[] modules = GetModulesInternal ();
 
                        if (!getResourceModules) {
-                               ArrayList result = new ArrayList (modules.Length);
+                               var result = new List<Module> (modules.Length);
                                foreach (Module m in modules)
                                        if (!m.IsResource ())
                                                result.Add (m);
-                               return (Module[])result.ToArray (typeof (Module));
+                               return result.ToArray ();
                        }
                        else
                                return modules;
@@ -143,7 +155,6 @@ namespace System.Reflection {
                        }
                }
 
-#if !MOONLIGHT
                public
 #if NET_4_0
                override
@@ -153,8 +164,6 @@ namespace System.Reflection {
                                return get_global_assembly_cache ();
                        }
                }
-#endif
-
        }
 }