Skip to content

Commit a510f5b

Browse files
Add System.Reflection usage to dotnet.aotprofile
1 parent b86a7d7 commit a510f5b

File tree

4 files changed

+277
-23
lines changed

4 files changed

+277
-23
lines changed

src/profiled-aot/CommonMethods.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
// int.Parse(), int.ToString()
55
// Culture-aware string comparisons
66
// ResourceManager
7+
// System.Reflection
78
// System.Threading.Tasks.Task
89
// System.Net.Http.HttpClient
910

1011
// Opt out of this warning, because we actually *want* culture-aware string behavior in the AOT profile
1112
#pragma warning disable CA1310
1213

14+
using System.Reflection;
15+
1316
static class CommonMethods
1417
{
1518
// Returns '200 OK' if the caller wants to set that on the UI
@@ -26,6 +29,10 @@ public static async Task<string> Invoke()
2629

2730
string someString = AndroidProfiledAot.Resources.Strings.SomeString;
2831

32+
var type = typeof (CommonMethods);
33+
var method = type.GetMethod (nameof (FromReflection), BindingFlags.NonPublic | BindingFlags.Static);
34+
method.Invoke (null, null);
35+
2936
using var client = new HttpClient();
3037
var send = client.SendAsync (new HttpRequestMessage (HttpMethod.Get, url));
3138
var getstring = client.GetStringAsync (url);
@@ -34,6 +41,8 @@ public static async Task<string> Invoke()
3441

3542
return text;
3643
}
44+
45+
static void FromReflection () { }
3746
}
3847

3948
#pragma warning restore CA1310

src/profiled-aot/android/MainActivity.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ namespace android;
33
[Activity(Label = "@string/app_name", MainLauncher = true)]
44
public class MainActivity : Activity
55
{
6-
protected override void OnCreate(Bundle? savedInstanceState)
6+
protected async override void OnCreate(Bundle? savedInstanceState)
77
{
88
base.OnCreate(savedInstanceState);
99

10-
_ = CommonMethods.Invoke();
11-
1210
// Set our view from the "main" layout resource
1311
SetContentView(Resource.Layout.activity_main);
12+
13+
await CommonMethods.Invoke();
1414
}
1515
}

src/profiled-aot/dotnet.aotprofile

21.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)