-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Microsoft.Android.Sdk.ILLink] fix crash when TZ changes
Fixes: #7953 **WIP** seeing what the test does on CI. When a timezone changes in a `Release` app, it can crash with: [monodroid] Unable to find Android.Runtime.AndroidEnvironment.NotifyTimeZoneChanged()! In 11f0e1b, we removed the line: <?xml version="1.0" encoding="utf-8" ?> <linker> <assembly fullname="Mono.Android"> -- <type fullname="Android.Runtime.AndroidEnvironment" /> Unfortunately, this method is called from native code, so we need to *always* preserve it. Added a test for this scenario, we may want to audit all `mono_class_get_method_from_name` calls and add more tests cases. I also cleaned up the tests a bit with a `getResource()` local function.
- Loading branch information
1 parent
ecb207b
commit 919fcd2
Showing
4 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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
19 changes: 19 additions & 0 deletions
19
tests/MSBuildDeviceIntegration/Resources/LinkDescTest/PreserveTest.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
public class PreserveTest | ||
{ | ||
// [Test] | ||
public static string MethodsArePreserved () | ||
{ | ||
try { | ||
// See src/monodroid/jni/timezones.cc for usage | ||
var type = Type.GetType ("Android.Runtime.AndroidEnvironment, Mono.Android"); | ||
var method = type.GetMethod ("NotifyTimeZoneChanged", BindingFlags.Instance | BindingFlags.NonPublic); | ||
method.Invoke (null, null); | ||
return $"[PASS] {nameof (PreserveTest)}.{nameof (MethodsArePreserved)}"; | ||
} catch (Exception ex) { | ||
return $"[FAIL] {nameof (PreserveTest)}.{nameof (MethodsArePreserved)} FAILED: {ex}"; | ||
} | ||
} | ||
} |
This file contains 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