Permalink
Browse files

2007-09-18 Marek Habersack <mhabersack@novell.com>

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

2007-09-18  Marek Habersack  <mhabersack@novell.com>

            * 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  <mhabersack@novell.com>

            * 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.



svn path=/trunk/mono/; revision=85971
  • Loading branch information...
1 parent 1269d67 commit e486bfc64a35d3a426cf440458540db455d95b6d @grendello grendello committed Sep 18, 2007
View
@@ -1,3 +1,8 @@
+2007-09-18 Marek Habersack <mhabersack@novell.com>
+
+ * configure.in: added additional Makefile to be generated in the
+ mono/tests/assemblyresolve/ subdir.
+
2007-09-17 Zoltan Varga <vargaz@gmail.com>
* docs/memory-management.txt: A new file describing metadata memory management.
View
@@ -2076,6 +2076,7 @@ mono/arch/mips/Makefile
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
@@ -1,3 +1,19 @@
+2007-09-18 Marek Habersack <mhabersack@novell.com>
+
+ * 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 <vargaz@gmail.com>
* class.c (mono_class_init): Make sure class->methods and class->properties
@@ -114,6 +114,8 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
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 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
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){
@@ -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 @@ mono_assembly_load_with_partial_name (const char *name, MonoImageOpenStatus *sta
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 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *
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 @@ mono_assembly_load_full (MonoAssemblyName *aname, const char *basedir, MonoImage
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;
}
@@ -332,4 +332,9 @@ mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointe
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__ */
View
@@ -1,3 +1,16 @@
+2007-09-18 Marek Habersack <mhabersack@novell.com>
+
+ * 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 <massi@ximian.com>
* Makefile.am: Fixed and re-enabled test for bug #82416 (the
@@ -1,4 +1,4 @@
-SUBDIRS = cas
+SUBDIRS = cas assemblyresolve
check-local: test
@@ -44,6 +44,7 @@ TEST_CS_SRC= \
array-init.cs \
arraylist.cs \
assemblyresolve_event.cs \
+ assemblyresolve_event3.cs \
checked.cs \
char-isnumber.cs \
create-instance.cs \
@@ -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
@@ -0,0 +1,8 @@
+using System;
+using TestBase;
+
+namespace Test
+{
+ public class Test : TestBase.TestBase
+ {}
+}
@@ -0,0 +1,7 @@
+using System;
+
+namespace TestBase
+{
+ public class TestBase
+ {}
+}
@@ -0,0 +1,12 @@
+using System;
+using Test;
+
+public class Asm : Test.Test
+{
+ Test.Test t;
+
+ public Asm ()
+ {
+ t = new Test.Test ();
+ }
+}
@@ -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;
+ }
+}

0 comments on commit e486bfc

Please sign in to comment.