-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[WASM] Add satellite assemblies bundle and hook to register them #41358
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
Merged
safern
merged 8 commits into
dotnet:master
from
safern:wasm-enableassemblyloadcontexttest
Sep 8, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6880436
[WASM] Add satellite assemblies bundle and hook to register them
safern 1f47374
Merge remote-tracking branch 'dotnet/master' into wasm-enableassembly…
safern eea892b
Fix test failures
safern 88ceafb
PR Feedback
safern 7815467
PR Feedback and add test to make sure load from path respects culture
safern 8549cbc
Add binding so that blazor can register bundled assemblies
safern bd50f66
Remove blank line.
safern 42d8926
PR Feedback
safern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1846,34 +1846,75 @@ mono_image_loaded_by_guid (const char *guid) | |
| return mono_image_loaded_by_guid_internal (guid, FALSE); | ||
| } | ||
|
|
||
| static const char * | ||
| get_image_culture (MonoImage *image) | ||
| { | ||
| MonoTableInfo *t = &image->tables [MONO_TABLE_ASSEMBLY]; | ||
| if (!t->rows) | ||
| return NULL; | ||
|
|
||
| guint32 cols [MONO_ASSEMBLY_SIZE]; | ||
| mono_metadata_decode_row (t, 0, cols, MONO_ASSEMBLY_SIZE); | ||
| return mono_metadata_string_heap (image, cols [MONO_ASSEMBLY_CULTURE]); | ||
| } | ||
|
|
||
| char * | ||
| mono_image_get_name_with_culture_if_needed (MonoImage *image) | ||
| { | ||
| if (!g_str_has_prefix (image->name, "data-") && | ||
safern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| !g_path_is_absolute (image->name)) | ||
| { | ||
| const char *culture = get_image_culture (image); | ||
|
|
||
| if (culture && culture [0] != 0) | ||
| return g_strdup_printf ("%s/%s", culture, image->name); | ||
| } | ||
|
|
||
| return NULL; | ||
| } | ||
|
|
||
| static MonoImage * | ||
| register_image (MonoLoadedImages *li, MonoImage *image, gboolean *problematic) | ||
| { | ||
| MonoImage *image2; | ||
| char *name = image->name; | ||
| #ifdef ENABLE_NETCORE | ||
| /* Since we register cultures by file name, we need to make this culture aware for | ||
| satellite assemblies */ | ||
| char *name_with_culture = mono_image_get_name_with_culture_if_needed (image); | ||
safern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (name_with_culture) | ||
| name = name_with_culture; | ||
| #endif | ||
| GHashTable *loaded_images = mono_loaded_images_get_hash (li, image->ref_only); | ||
|
|
||
| mono_images_lock (); | ||
| image2 = (MonoImage *)g_hash_table_lookup (loaded_images, image->name); | ||
| image2 = (MonoImage *)g_hash_table_lookup (loaded_images, name); | ||
|
|
||
| if (image2) { | ||
| /* Somebody else beat us to it */ | ||
| mono_image_addref (image2); | ||
| mono_images_unlock (); | ||
| mono_image_close (image); | ||
| #ifdef ENABLE_NETCORE | ||
| g_free (name_with_culture); | ||
| #endif | ||
| return image2; | ||
| } | ||
|
|
||
| GHashTable *loaded_images_by_name = mono_loaded_images_get_by_name_hash (li, image->ref_only); | ||
| g_hash_table_insert (loaded_images, image->name, image); | ||
| g_hash_table_insert (loaded_images, name, image); | ||
| if (image->assembly_name && (g_hash_table_lookup (loaded_images_by_name, image->assembly_name) == NULL)) | ||
| g_hash_table_insert (loaded_images_by_name, (char *) image->assembly_name, image); | ||
| mono_images_unlock (); | ||
|
|
||
| if (mono_is_problematic_image (image)) { | ||
| mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Registering %s, problematic image '%s'", image->ref_only ? "REFONLY" : "default", image->name); | ||
| mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Registering %s, problematic image '%s'", image->ref_only ? "REFONLY" : "default", name); | ||
| if (problematic) | ||
| *problematic = TRUE; | ||
| } | ||
| #ifdef ENABLE_NETCORE | ||
| g_free (name_with_culture); | ||
| #endif | ||
| return image; | ||
| } | ||
|
|
||
|
|
@@ -2029,6 +2070,11 @@ mono_image_open_full (const char *fname, MonoImageOpenStatus *status, gboolean r | |
| return mono_image_open_a_lot (alc, fname, status, refonly, FALSE); | ||
| } | ||
|
|
||
| /** | ||
| * mono_image_open_a_lot_parameterized | ||
| * this API is not culture aware, so if we load a satellite assembly for one culture by name | ||
| * via this API, and then try to load it with another culture we will return the first one. | ||
| */ | ||
| static MonoImage * | ||
| mono_image_open_a_lot_parameterized (MonoLoadedImages *li, MonoAssemblyLoadContext *alc, const char *fname, MonoImageOpenStatus *status, gboolean refonly, gboolean load_from_context, gboolean *problematic) | ||
|
Comment on lines
+2073
to
2079
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this comment. |
||
| { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.