Author: raja
Date: 2006-11-14 07:23:20 -0500 (Tue, 14 Nov 2006)
New Revision: 67837

Modified:
   trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
   trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
Log:
* AssemblyTest.cs (bug79872): New test for #79872.


Modified: trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs       
2006-11-14 12:08:24 UTC (rev 67836)
+++ trunk/mcs/class/corlib/Test/System.Reflection/AssemblyTest.cs       
2006-11-14 12:23:20 UTC (rev 67837)
@@ -844,6 +844,60 @@
                        }
                }
 
+               [Test]
+               public void bug79872 ()
+               {
+                       Random rnd = new Random ();
+                       string outdir;
+                       int tries = 0;
+
+               retry:
+                       outdir = Path.Combine (Path.GetTempPath (), "bug79872-" 
+ rnd.Next (10000, 99999));
+                       if (Directory.Exists (outdir)) {
+                               try {
+                                       Directory.Delete (outdir, true);
+                               } catch {
+                                       if (++tries <= 100)
+                                               goto retry;
+                               }
+                       }
+
+                       Directory.CreateDirectory (outdir);
+
+                       AssemblyName an = new AssemblyName ();
+                       an.Name = "bug79872";
+                       AssemblyBuilder ab = 
AppDomain.CurrentDomain.DefineDynamicAssembly (an, AssemblyBuilderAccess.Save, 
outdir);
+                       string dllname = "bug79872.dll";
+                       ModuleBuilder mb1 = ab.DefineDynamicModule ("bug79872", 
dllname);
+                       string netmodule = "bug79872.netmodule";
+                       ModuleBuilder mb2 = ab.DefineDynamicModule (netmodule, 
netmodule);
+                       TypeBuilder a1 = mb2.DefineType ("A");
+                       a1.CreateType ();
+                       ab.Save (dllname);
+
+                       bool ok = true;
+                       try {
+                               Assembly.LoadFrom (Path.Combine (outdir, 
dllname));
+                       } catch {
+                               ok = false;
+                       }
+                       Assert.IsTrue (ok, "Should load a .NET metadata file 
with an assembly manifest");
+
+                       ok = false;
+                       try {
+                               Assembly.LoadFrom (Path.Combine (outdir, 
netmodule));
+                       } catch (BadImageFormatException) {
+                               ok = true; // mono and .net 2.0 throw this
+                       } catch (FileLoadException) {
+                               ok = true; // .net 1.1 throws this
+                       } catch {
+                               // swallow the rest
+                       }
+                       Assert.IsTrue (ok, "Complain on loading a .NET metadata 
file without an assembly manifest");
+
+                       Directory.Delete (outdir, true);
+               }
+
                [Serializable ()]
                private class AssemblyResolveHandler
                {

Modified: trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2006-11-14 
12:08:24 UTC (rev 67836)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2006-11-14 
12:23:20 UTC (rev 67837)
@@ -1,3 +1,7 @@
+2006-11-14  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * AssemblyTest.cs (bug79872): New test for #79872.
+
 2006-10-22  Gert Driesen  <[EMAIL PROTECTED]>
 
        * AssemblyTest.cs: Added tests for bug #79712 and #79715. All marked

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to