Skip to content

Commit b247588

Browse files
committed
set isAotCompatible=true
1 parent 4cae0fb commit b247588

File tree

8 files changed

+36
-8
lines changed

8 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## 2.3.1
2+
- set isAotCompatible=true
23
- test : Microsoft.Maui.* 9.0.10
34

45
## 2.3.0

SecureHttpClient.OkHttp/SecureHttpClient.OkHttp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net9.0-android35.0</TargetFrameworks>
5+
<IsAotCompatible>true</IsAotCompatible>
56
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
67
</PropertyGroup>
78

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json;
3+
4+
namespace SecureHttpClient.Test.Helpers
5+
{
6+
public static class JsonExtensions
7+
{
8+
public static Dictionary<string, string> GetDictionary(this JsonElement jsonElement)
9+
{
10+
var d = new Dictionary<string, string>();
11+
foreach (var p in jsonElement.EnumerateObject())
12+
{
13+
d[p.Name] = p.Value.GetString();
14+
}
15+
return d;
16+
}
17+
}
18+
}

SecureHttpClient.Test/HttpTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public async Task HttpTest_Headers()
116116
req.Headers.Add("header3", "value3");
117117
var result = await SendAsync(req).ReceiveString();
118118
var json = JsonDocument.Parse(result);
119-
var headers = json.RootElement.GetProperty("headers").Deserialize<Dictionary<string, string>>().Select(kv => kv.Key).ToList();
119+
var headers = json.RootElement.GetProperty("headers").GetDictionary().Select(kv => kv.Key).ToList();
120120
Assert.Contains("header1", headers);
121121
Assert.Contains("header2", headers);
122122
Assert.Contains("header3", headers);
@@ -135,7 +135,7 @@ public async Task HttpTest_HeadersOrder()
135135
req.SetHeadersOrder("header3", "header2", "header1");
136136
var result = await SendAsync(req).ReceiveString();
137137
var json = JsonDocument.Parse(result);
138-
var headers = json.RootElement.GetProperty("headers").Deserialize<Dictionary<string, string>>().Select(kv => kv.Key).ToList();
138+
var headers = json.RootElement.GetProperty("headers").GetDictionary().Select(kv => kv.Key).ToList();
139139
var index1 = headers.IndexOf("header1");
140140
var index2 = headers.IndexOf("header2");
141141
var index3 = headers.IndexOf("header3");
@@ -220,7 +220,7 @@ public async Task HttpTest_SetCookie()
220220
const string page = @"https://httpbingo.org/cookies/set?k1=v1";
221221
var result = await GetAsync(page).ReceiveString();
222222
var json = JsonDocument.Parse(result);
223-
var cookies = json.RootElement.Deserialize<Dictionary<string, string>>();
223+
var cookies = json.RootElement.GetDictionary();
224224
Assert.Contains(new KeyValuePair<string, string>("k1", "v1"), cookies);
225225
}
226226

@@ -232,7 +232,7 @@ public async Task HttpTest_SetCookieAgain()
232232
const string page2 = @"https://httpbingo.org/cookies/set?k1=v2";
233233
var result = await GetAsync(page2).ReceiveString();
234234
var json = JsonDocument.Parse(result);
235-
var cookies = json.RootElement.Deserialize<Dictionary<string, string>>();
235+
var cookies = json.RootElement.GetDictionary();
236236
Assert.Contains(new KeyValuePair<string, string>("k1", "v2"), cookies);
237237
}
238238

@@ -248,7 +248,7 @@ public async Task HttpTest_SetCookies()
248248
const string page2 = @"https://httpbingo.org/cookies";
249249
var result = await GetAsync(page2).ReceiveString();
250250
var json = JsonDocument.Parse(result);
251-
var cookies = json.RootElement.Deserialize<Dictionary<string, string>>();
251+
var cookies = json.RootElement.GetDictionary();
252252
Assert.Contains(new KeyValuePair<string, string>("k1", "v1"), cookies);
253253
Assert.Contains(new KeyValuePair<string, string>("k2", "v2"), cookies);
254254
}
@@ -263,7 +263,7 @@ public async Task HttpTest_DeleteCookie()
263263
const string page2 = @"https://httpbingo.org/cookies/delete?k1";
264264
var result = await GetAsync(page2).ReceiveString();
265265
var json = JsonDocument.Parse(result);
266-
var cookies = json.RootElement.Deserialize<Dictionary<string, string>>();
266+
var cookies = json.RootElement.GetDictionary();
267267
Assert.DoesNotContain(new KeyValuePair<string, string>("k1", "v1"), cookies);
268268
}
269269

@@ -274,7 +274,7 @@ public async Task HttpTest_DoNotUseCookies()
274274
DisableCookies();
275275
var result = await GetAsync(page).ReceiveString();
276276
var json = JsonDocument.Parse(result);
277-
var cookies = json.RootElement.Deserialize<Dictionary<string, string>>();
277+
var cookies = json.RootElement.GetDictionary();
278278
Assert.Empty(cookies);
279279
}
280280

SecureHttpClient.Test/SecureHttpClient.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
5+
<IsAotCompatible>true</IsAotCompatible>
56
</PropertyGroup>
67

78
<ItemGroup>

SecureHttpClient.TestRunner.Maui/SecureHttpClient.TestRunner.Maui.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<UseMaui>true</UseMaui>
99
<SingleProject>true</SingleProject>
1010
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
11+
<IsAotCompatible>true</IsAotCompatible>
1112

1213
<!-- ILxxxx is for trimmer -->
1314
<NoWarn>$(NoWarn);IL2026;IL2104</NoWarn>
@@ -40,7 +41,7 @@
4041
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
4142
<AndroidAotAdditionalArguments>no-write-symbols,nodebug</AndroidAotAdditionalArguments>
4243
<TrimMode>full</TrimMode>
43-
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
44+
<PublishTrimmed>true</PublishTrimmed>
4445
<AndroidStripILAfterAOT>true</AndroidStripILAfterAOT>
4546
</PropertyGroup>
4647

SecureHttpClient.TestRunner.Net/SecureHttpClient.TestRunner.Net.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
55
<OutputType>Exe</OutputType>
6+
<IsAotCompatible>true</IsAotCompatible>
7+
</PropertyGroup>
8+
9+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
10+
<PublishAot>true</PublishAot>
611
</PropertyGroup>
712

813
<ItemGroup>

SecureHttpClient/SecureHttpClient.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
66
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
77
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
8+
<IsAotCompatible>true</IsAotCompatible>
89
</PropertyGroup>
910

1011
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">

0 commit comments

Comments
 (0)