Author: mhabersack
Date: 2007-09-18 10:34:08 -0400 (Tue, 18 Sep 2007)
New Revision: 85971

Added:
   trunk/mono/mono/tests/assemblyresolve/
   trunk/mono/mono/tests/assemblyresolve/Makefile.am
   trunk/mono/mono/tests/assemblyresolve/Test.cs
   trunk/mono/mono/tests/assemblyresolve/TestBase.cs
   trunk/mono/mono/tests/assemblyresolve/asm.cs
   trunk/mono/mono/tests/assemblyresolve_event3.cs
Modified:
   trunk/mono/ChangeLog
   trunk/mono/configure.in
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/appdomain.c
   trunk/mono/mono/metadata/assembly.c
   trunk/mono/mono/metadata/domain-internals.h
   trunk/mono/mono/tests/ChangeLog
   trunk/mono/mono/tests/Makefile.am
Log:
2007-09-18  Marek Habersack  <[EMAIL PROTECTED]>

            * configure.in: added additional Makefile to be generated in the
            mono/tests/assemblyresolve/ subdir.

2007-09-18  Marek Habersack  <[EMAIL PROTECTED]>

            * assemblyresolve/asm.cs: added

            * assemblyresolve/TestBase.cs: added

            * assemblyresolve/Test.cs: added

            * assemblyresolve/Makefile.am: added

            * assemblyresolve_event3.cs: added new AssemblyResolve event
            test.

2007-09-18  Marek Habersack  <[EMAIL PROTECTED]>

            * domain-internals.h: added a declaration of the
            mono_assembly_load_full_nosearch internal function.

            * assembly.c (mono_assembly_load_with_partial_name): use
            mono_try_assembly_resolve return value properly.
            (mono_assembly_load_full_nosearch): copied the function body from
            mono_assembly_load_full, without the code to invoke assembly
            search hooks.
            (mono_assembly_load_full): calls the above new function and if the
            assembly is not resolved, invokes the search hooks.

            * appdomain.c (mono_runtime_init): restore the global postload
            assembly search handlers.




Modified: trunk/mono/ChangeLog
===================================================================
--- trunk/mono/ChangeLog        2007-09-18 14:02:39 UTC (rev 85970)
+++ trunk/mono/ChangeLog        2007-09-18 14:34:08 UTC (rev 85971)
@@ -1,3 +1,8 @@
+2007-09-18  Marek Habersack  <[EMAIL PROTECTED]>
+
+       * configure.in: added additional Makefile to be generated in the
+       mono/tests/assemblyresolve/ subdir.
+
 2007-09-17  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * docs/memory-management.txt: A new file describing metadata memory 
management.

Modified: trunk/mono/configure.in
===================================================================
--- trunk/mono/configure.in     2007-09-18 14:02:39 UTC (rev 85970)
+++ trunk/mono/configure.in     2007-09-18 14:34:08 UTC (rev 85971)
@@ -2076,6 +2076,7 @@
 mono/interpreter/Makefile
 mono/tests/Makefile
 mono/tests/tests-config
+mono/tests/assemblyresolve/Makefile
 mono/tests/cas/Makefile
 mono/tests/cas/assembly/Makefile
 mono/tests/cas/demand/Makefile

Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-09-18 14:02:39 UTC (rev 85970)
+++ trunk/mono/mono/metadata/ChangeLog  2007-09-18 14:34:08 UTC (rev 85971)
@@ -1,3 +1,19 @@
+2007-09-18  Marek Habersack  <[EMAIL PROTECTED]>
+
+       * domain-internals.h: added a declaration of the
+       mono_assembly_load_full_nosearch internal function.
+
+       * assembly.c (mono_assembly_load_with_partial_name): use
+       mono_try_assembly_resolve return value properly.
+       (mono_assembly_load_full_nosearch): copied the function body from
+       mono_assembly_load_full, without the code to invoke assembly
+       search hooks.
+       (mono_assembly_load_full): calls the above new function and if the
+       assembly is not resolved, invokes the search hooks.
+
+       * appdomain.c (mono_runtime_init): restore the global postload
+       assembly search handlers.
+
 2007-09-18  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * class.c (mono_class_init): Make sure class->methods and 
class->properties

Modified: trunk/mono/mono/metadata/appdomain.c
===================================================================
--- trunk/mono/mono/metadata/appdomain.c        2007-09-18 14:02:39 UTC (rev 
85970)
+++ trunk/mono/mono/metadata/appdomain.c        2007-09-18 14:34:08 UTC (rev 
85971)
@@ -114,6 +114,8 @@
        mono_install_assembly_refonly_preload_hook 
(mono_domain_assembly_preload, GUINT_TO_POINTER (TRUE));
        mono_install_assembly_search_hook (mono_domain_assembly_search, 
GUINT_TO_POINTER (FALSE));
        mono_install_assembly_refonly_search_hook (mono_domain_assembly_search, 
GUINT_TO_POINTER (TRUE));
+       mono_install_assembly_postload_search_hook 
(mono_domain_assembly_postload_search, GUINT_TO_POINTER (FALSE));
+       mono_install_assembly_postload_refonly_search_hook 
(mono_domain_assembly_postload_search, GUINT_TO_POINTER (TRUE));
        mono_install_assembly_load_hook (mono_domain_fire_assembly_load, NULL);
        mono_install_lookup_dynamic_token 
(mono_reflection_lookup_dynamic_token);
 
@@ -1381,7 +1383,7 @@
                mono_raise_exception (exc);
        }
 
-       ass = mono_assembly_load_full (&aname, NULL, &status, refOnly);
+       ass = mono_assembly_load_full_nosearch (&aname, NULL, &status, refOnly);
        mono_assembly_name_free (&aname);
 
        if (!ass && (refass = mono_try_assembly_resolve (domain, assRef, 
refOnly)) == NULL){

Modified: trunk/mono/mono/metadata/assembly.c
===================================================================
--- trunk/mono/mono/metadata/assembly.c 2007-09-18 14:02:39 UTC (rev 85970)
+++ trunk/mono/mono/metadata/assembly.c 2007-09-18 14:34:08 UTC (rev 85971)
@@ -16,6 +16,7 @@
 #include "assembly.h"
 #include "image.h"
 #include "rawbuffer.h"
+#include "object-internals.h"
 #include <mono/metadata/loader.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/metadata/metadata-internals.h>
@@ -1922,7 +1923,9 @@
                res->in_gac = TRUE;
        else {
                MonoDomain *domain = mono_domain_get ();
-               res = mono_try_assembly_resolve (domain, mono_string_new 
(domain, name), FALSE);                
+               MonoReflectionAssembly *refasm = mono_try_assembly_resolve 
(domain, mono_string_new (domain, name), FALSE);
+               if (refasm)
+                       res = refasm->assembly;
        }
        
        g_free (fullname);
@@ -2177,24 +2180,10 @@
        return corlib;
 }
 
-/**
- * mono_assembly_load_full:
- * @aname: A MonoAssemblyName with the assembly name to load.
- * @basedir: A directory to look up the assembly at.
- * @status: a pointer to a MonoImageOpenStatus to return the status of the 
load operation
- * @refonly: Whether this assembly is being opened in "reflection-only" mode.
- *
- * Loads the assembly referenced by @aname, if the value of @basedir is not 
NULL, it
- * attempts to load the assembly from that directory before probing the 
standard locations.
- *
- * If the assembly is being opened in reflection-only mode (@refonly set to 
TRUE) then no 
- * assembly binding takes place.
- *
- * Returns: the assembly referenced by @aname loaded or NULL on error.   On 
error the
- * value pointed by status is updated with an error code.
- */
-MonoAssembly*
-mono_assembly_load_full (MonoAssemblyName *aname, const char *basedir, 
MonoImageOpenStatus *status, gboolean refonly)
+MonoAssembly* mono_assembly_load_full_nosearch (MonoAssemblyName *aname, 
+                                               const char       *basedir, 
+                                               MonoImageOpenStatus *status,
+                                               gboolean refonly)
 {
        MonoAssembly *result;
        char *fullpath, *filename;
@@ -2262,9 +2251,33 @@
                        return result;
        }
 
-       /* Try a postload search hook */
-       result = mono_assembly_invoke_search_hook_internal (aname, refonly, 
TRUE);
+       return result;
+}
 
+/**
+ * mono_assembly_load_full:
+ * @aname: A MonoAssemblyName with the assembly name to load.
+ * @basedir: A directory to look up the assembly at.
+ * @status: a pointer to a MonoImageOpenStatus to return the status of the 
load operation
+ * @refonly: Whether this assembly is being opened in "reflection-only" mode.
+ *
+ * Loads the assembly referenced by @aname, if the value of @basedir is not 
NULL, it
+ * attempts to load the assembly from that directory before probing the 
standard locations.
+ *
+ * If the assembly is being opened in reflection-only mode (@refonly set to 
TRUE) then no 
+ * assembly binding takes place.
+ *
+ * Returns: the assembly referenced by @aname loaded or NULL on error.   On 
error the
+ * value pointed by status is updated with an error code.
+ */
+MonoAssembly*
+mono_assembly_load_full (MonoAssemblyName *aname, const char *basedir, 
MonoImageOpenStatus *status, gboolean refonly)
+{
+       MonoAssembly *result = mono_assembly_load_full_nosearch (aname, 
basedir, status, refonly);
+       
+       if (!result)
+               /* Try a postload search hook */
+               result = mono_assembly_invoke_search_hook_internal (aname, 
refonly, TRUE);
        return result;
 }
 

Modified: trunk/mono/mono/metadata/domain-internals.h
===================================================================
--- trunk/mono/mono/metadata/domain-internals.h 2007-09-18 14:02:39 UTC (rev 
85970)
+++ trunk/mono/mono/metadata/domain-internals.h 2007-09-18 14:34:08 UTC (rev 
85971)
@@ -332,4 +332,9 @@
 MonoReflectionAssembly *
 mono_try_assembly_resolve (MonoDomain *domain, MonoString *fname, gboolean 
refonly) MONO_INTERNAL;
 
+MonoAssembly* mono_assembly_load_full_nosearch (MonoAssemblyName *aname, 
+                                               const char       *basedir, 
+                                               MonoImageOpenStatus *status,
+                                               gboolean refonly) MONO_INTERNAL;
+
 #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */

Modified: trunk/mono/mono/tests/ChangeLog
===================================================================
--- trunk/mono/mono/tests/ChangeLog     2007-09-18 14:02:39 UTC (rev 85970)
+++ trunk/mono/mono/tests/ChangeLog     2007-09-18 14:34:08 UTC (rev 85971)
@@ -1,3 +1,16 @@
+2007-09-18  Marek Habersack  <[EMAIL PROTECTED]>
+
+       * assemblyresolve/asm.cs: added
+
+       * assemblyresolve/TestBase.cs: added
+
+       * assemblyresolve/Test.cs: added
+
+       * assemblyresolve/Makefile.am: added
+
+       * assemblyresolve_event3.cs: added new AssemblyResolve event
+       test.
+
 2007-09-13  Massimiliano Mantione  <[EMAIL PROTECTED]>
 
        * Makefile.am: Fixed and re-enabled test for bug #82416 (the

Modified: trunk/mono/mono/tests/Makefile.am
===================================================================
--- trunk/mono/mono/tests/Makefile.am   2007-09-18 14:02:39 UTC (rev 85970)
+++ trunk/mono/mono/tests/Makefile.am   2007-09-18 14:34:08 UTC (rev 85971)
@@ -1,4 +1,4 @@
-SUBDIRS = cas
+SUBDIRS = cas assemblyresolve
 
 check-local: test
 
@@ -44,6 +44,7 @@
        array-init.cs           \
        arraylist.cs            \
        assemblyresolve_event.cs        \
+       assemblyresolve_event3.cs       \
        checked.cs              \
        char-isnumber.cs        \
        create-instance.cs      \

Added: trunk/mono/mono/tests/assemblyresolve/Makefile.am
===================================================================
--- trunk/mono/mono/tests/assemblyresolve/Makefile.am   2007-09-18 14:02:39 UTC 
(rev 85970)
+++ trunk/mono/mono/tests/assemblyresolve/Makefile.am   2007-09-18 14:34:08 UTC 
(rev 85971)
@@ -0,0 +1,19 @@
+with_mono_path = MONO_PATH=$(mcs_topdir)/class/lib/default
+
+RUNTIME = $(with_mono_path) $(top_builddir)/runtime/mono-wrapper --debug 
--security
+MCS = $(RUNTIME) $(mcs_topdir)/class/lib/default/mcs.exe -debug:full 
-target:library
+
+all: prereq test/asm.dll
+
+test/asm.dll: deps/test.dll asm.cs
+       $(MCS) -out:test/asm.dll -r:deps/test.dll asm.cs
+
+deps/test.dll: deps/TestBase.dll Test.cs
+       $(MCS) -out:deps/test.dll -r:deps/TestBase.dll Test.cs
+
+deps/TestBase.dll: TestBase.cs
+       $(MCS) -out:deps/TestBase.dll TestBase.cs
+
+prereq:
+       @-mkdir test
+       @-mkdir deps

Added: trunk/mono/mono/tests/assemblyresolve/Test.cs
===================================================================
--- trunk/mono/mono/tests/assemblyresolve/Test.cs       2007-09-18 14:02:39 UTC 
(rev 85970)
+++ trunk/mono/mono/tests/assemblyresolve/Test.cs       2007-09-18 14:34:08 UTC 
(rev 85971)
@@ -0,0 +1,8 @@
+using System;
+using TestBase;
+
+namespace Test
+{
+  public class Test : TestBase.TestBase
+  {}
+}


Property changes on: trunk/mono/mono/tests/assemblyresolve/Test.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mono/mono/tests/assemblyresolve/TestBase.cs
===================================================================
--- trunk/mono/mono/tests/assemblyresolve/TestBase.cs   2007-09-18 14:02:39 UTC 
(rev 85970)
+++ trunk/mono/mono/tests/assemblyresolve/TestBase.cs   2007-09-18 14:34:08 UTC 
(rev 85971)
@@ -0,0 +1,7 @@
+using System;
+
+namespace TestBase
+{
+  public class TestBase
+  {}
+}


Property changes on: trunk/mono/mono/tests/assemblyresolve/TestBase.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mono/mono/tests/assemblyresolve/asm.cs
===================================================================
--- trunk/mono/mono/tests/assemblyresolve/asm.cs        2007-09-18 14:02:39 UTC 
(rev 85970)
+++ trunk/mono/mono/tests/assemblyresolve/asm.cs        2007-09-18 14:34:08 UTC 
(rev 85971)
@@ -0,0 +1,12 @@
+using System;
+using Test;
+
+public class Asm : Test.Test
+{
+  Test.Test t;
+  
+  public Asm ()
+  {
+    t = new Test.Test ();
+  }
+}


Property changes on: trunk/mono/mono/tests/assemblyresolve/asm.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mono/mono/tests/assemblyresolve_event3.cs
===================================================================
--- trunk/mono/mono/tests/assemblyresolve_event3.cs     2007-09-18 14:02:39 UTC 
(rev 85970)
+++ trunk/mono/mono/tests/assemblyresolve_event3.cs     2007-09-18 14:34:08 UTC 
(rev 85971)
@@ -0,0 +1,41 @@
+using System;
+using System.IO;
+using System.Reflection;
+
+class App
+{
+       const int expected_count = 1;
+       static int event_handler_count;
+       
+       public static int Main ()
+       {
+               AppDomain.CurrentDomain.AssemblyResolve += new 
ResolveEventHandler (MyResolveEventHandler);
+               
+               event_handler_count = 0;
+               try {
+                       Assembly a = Assembly.LoadFile (String.Format 
("{0}{1}assemblyresolve{1}test{1}asm.dll", Directory.GetCurrentDirectory (), 
Path.DirectorySeparatorChar));
+                       foreach (Type t in a.GetTypes ()) {
+                               Console.WriteLine ("pp: " + t + " " + 
t.BaseType);
+                       }
+               } catch (Exception ex) {
+                       Console.WriteLine ("Caught exception: {0}", ex.Message);
+                       return 1;
+               }
+               
+               if (event_handler_count != expected_count)
+                       return 2;
+                               
+               return 0;
+       }
+       
+       static Assembly MyResolveEventHandler (object sender, ResolveEventArgs 
args)
+       {
+               event_handler_count++;
+               Console.WriteLine ("Resolve assembly: {0}", args.Name);
+               if (args.Name == "test, Version=0.0.0.0, Culture=neutral" || 
args.Name == "test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")
+                       return Assembly.LoadFile (String.Format 
("{0}{1}assemblyresolve{1}deps{1}test.dll", Directory.GetCurrentDirectory (), 
Path.DirectorySeparatorChar));
+               if (args.Name == "TestBase, Version=0.0.0.0, Culture=neutral" 
|| args.Name == "TestBase, Version=0.0.0.0, Culture=neutral, 
PublicKeyToken=null")
+                       return Assembly.LoadFile (String.Format 
("{0}{1}assemblyresolve{1}deps{1}TestBase.dll", Directory.GetCurrentDirectory 
(), Path.DirectorySeparatorChar));
+               return null;
+       }
+}

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

Reply via email to