Skip to content

Commit

Permalink
[dotnet] Call monovm_initialize before mono_jit_init
Browse files Browse the repository at this point in the history
Those are called respectively inside `xamarin_vm_initialize` and
`xamarin_bridge_initialize` functions.

This fix the **AppContext.GetData always return null for iOS** issue
dotnet/runtime#50290

Added unit tests to ensure `AppContext.GetData` can read back the values
we're providing at startup.
  • Loading branch information
spouliot committed Mar 29, 2021
1 parent 9c0d466 commit 4ff2907
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions runtime/monotouch-main.m
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,10 @@ - (void) memoryWarning: (NSNotification *) sender
xamarin_initialize_cocoa_threads (NULL);
#endif

xamarin_bridge_initialize ();

#if DOTNET
xamarin_vm_initialize ();
#endif
xamarin_bridge_initialize ();

xamarin_initialize ();
DEBUG_LAUNCH_TIME_PRINT ("\tmonotouch init time");
Expand Down
9 changes: 9 additions & 0 deletions tests/linker/CommonLinkAnyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,14 @@ public static void Bug7114 ([CallerFilePath] string filePath = null)
Assert.IsNotNull (filePath, "CallerFilePath");
}

#if NET
[Test]
public void AppContextGetData ()
{
// https://github.com/dotnet/runtime/issues/50290
Assert.IsNotNull (AppContext.GetData ("APP_PATHS"), "APP_PATHS");
Assert.IsNotNull (AppContext.GetData ("PINVOKE_OVERRIDE"), "PINVOKE_OVERRIDE");
}
#endif
}
}

0 comments on commit 4ff2907

Please sign in to comment.