Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono] Invoke AssemblyLoad hooks from RuntimeAssemblyBuilder:.ctor ()… #85307

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ private static void OnAssemblyLoad(RuntimeAssembly assembly)
return InvokeResolveEvent(AssemblyResolve, assembly, assemblyFullName);
}

internal static void InvokeAssemblyLoadEvent(Assembly assembly)
{
AssemblyLoad?.Invoke(AppDomain.CurrentDomain, new AssemblyLoadEventArgs(assembly));
}

[UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file",
Justification = "The code handles the Assembly.Location equals null")]
private static RuntimeAssembly? InvokeResolveEvent(ResolveEventHandler? eventHandler, RuntimeAssembly? assembly, string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ internal RuntimeAssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access)
// Netcore only allows one module per assembly
manifest_module = new RuntimeModuleBuilder(this, "RefEmit_InMemoryManifestModule");
modules = new RuntimeModuleBuilder[] { manifest_module };

AssemblyLoadContext.InvokeAssemblyLoadEvent (this);
}

public override bool ReflectionOnly
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/metadata/appdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@ mono_domain_fire_assembly_load_event (MonoDomain *domain, MonoAssembly *assembly
if (!method)
goto exit;

if (assembly->dynamic)
/* Called by RuntimeAssemblyBuilder:.ctor () after the manifest module has been created */
goto exit;

MonoReflectionAssemblyHandle assembly_handle;
assembly_handle = mono_assembly_get_object_handle (assembly, error);
goto_if_nok (error, exit);
Expand Down