Skip to content

Commit dc43bd6

Browse files
committed
AOT适配
1 parent 4829443 commit dc43bd6

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8-
<ApplicationManifest></ApplicationManifest>
9-
<!--<PublishAot>true</PublishAot>
10-
<RuntimeIdentifier>win-x64</RuntimeIdentifier>-->
8+
<PublishAot>true</PublishAot>
9+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
10+
<JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class GeneralClientBootstrap : AbstractBootstrap<GeneralClientBootstrap,
4141
/// <returns></returns>
4242
public override async Task<GeneralClientBootstrap> LaunchAsync()
4343
{
44+
CallSmallBowlHome(_configinfo.Bowl);
4445
ExecuteCustomOptions();
4546
ClearEnvironmentVariable();
4647
await ExecuteWorkflowAsync();
@@ -143,16 +144,14 @@ private async Task ExecuteWorkflowAsync()
143144
, AppType.ClientApp
144145
,_configinfo.AppSecretKey
145146
,_configinfo.Platform
146-
,_configinfo.ProductId
147-
, VersionRespJsonContext.Default.VersionRespDTO);
147+
,_configinfo.ProductId);
148148

149149
var upgradeResp = await VersionService.Validate(_configinfo.UpdateUrl
150150
, _configinfo.UpgradeClientVersion
151151
, AppType.UpgradeApp
152152
,_configinfo.AppSecretKey
153153
,_configinfo.Platform
154-
,_configinfo.ProductId
155-
, VersionRespJsonContext.Default.VersionRespDTO);
154+
,_configinfo.ProductId);
156155

157156
_configinfo.IsUpgradeUpdate = CheckUpgrade(upgradeResp);
158157
_configinfo.IsMainUpdate = CheckUpgrade(mainResp);
@@ -331,7 +330,6 @@ private void CallSmallBowlHome(string processName)
331330
/// <returns></returns>
332331
private void ExecuteCustomOptions()
333332
{
334-
CallSmallBowlHome(_configinfo.Bowl);
335333
if (!_customOptions.Any()) return;
336334

337335
foreach (var option in _customOptions)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
4+
namespace GeneralUpdate.Common.AOT.JsonContext;
5+
6+
[JsonSerializable(typeof(bool))]
7+
[JsonSerializable(typeof(bool?))]
8+
[JsonSerializable(typeof(int))]
9+
[JsonSerializable(typeof(int?))]
10+
[JsonSerializable(typeof(string))]
11+
[JsonSerializable(typeof(Dictionary<string, object>))]
12+
public partial class HttpParameterJsonContext: JsonSerializerContext;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using System.Text.Json.Serialization;
2+
using GeneralUpdate.Common.Shared.Object;
3+
4+
namespace GeneralUpdate.Common.AOT.JsonContext;
5+
6+
[JsonSerializable(typeof(BaseResponseDTO<bool>))]
7+
public partial class ReportRespJsonContext : JsonSerializerContext;

src/c#/GeneralUpdate.Common/Shared/Service/VersionService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Text.Json.Serialization;
1010
using System.Text.Json.Serialization.Metadata;
1111
using System.Threading.Tasks;
12+
using GeneralUpdate.Common.AOT.JsonContext;
1213
using GeneralUpdate.Common.Shared.Object;
1314

1415
namespace GeneralUpdate.Common.Shared.Service
@@ -36,7 +37,7 @@ public static async Task Report(string httpUrl
3637
{ "Status", status },
3738
{ "Type", type }
3839
};
39-
await PostTaskAsync<BaseResponseDTO<bool>>(httpUrl, parameters);
40+
await PostTaskAsync<BaseResponseDTO<bool>>(httpUrl, parameters, ReportRespJsonContext.Default.BaseResponseDTOBoolean);
4041
}
4142

4243
/// <summary>
@@ -54,8 +55,7 @@ public static async Task<VersionRespDTO> Validate(string httpUrl
5455
, int appType
5556
, string appKey
5657
, int platform
57-
, string productId
58-
, JsonTypeInfo<VersionRespDTO>? typeInfo = null)
58+
, string productId)
5959
{
6060
var parameters = new Dictionary<string, object>
6161
{
@@ -65,7 +65,7 @@ public static async Task<VersionRespDTO> Validate(string httpUrl
6565
{ "Platform", platform },
6666
{ "ProductId", productId }
6767
};
68-
return await PostTaskAsync<VersionRespDTO>(httpUrl, parameters, typeInfo);
68+
return await PostTaskAsync<VersionRespDTO>(httpUrl, parameters, VersionRespJsonContext.Default.VersionRespDTO);
6969
}
7070

7171
private static async Task<T> PostTaskAsync<T>(string httpUrl, Dictionary<string, object> parameters, JsonTypeInfo<T>? typeInfo = null)
@@ -77,7 +77,7 @@ private static async Task<T> PostTaskAsync<T>(string httpUrl, Dictionary<string,
7777
});
7878
httpClient.Timeout = TimeSpan.FromSeconds(15);
7979
httpClient.DefaultRequestHeaders.Accept.ParseAdd("text/html, application/xhtml+xml, */*");
80-
string parametersJson = JsonSerializer.Serialize(parameters);
80+
var parametersJson = JsonSerializer.Serialize(parameters, HttpParameterJsonContext.Default.DictionaryStringObject);
8181
var stringContent = new StringContent(parametersJson, Encoding.UTF8, "application/json");
8282
var result = await httpClient.PostAsync(uri, stringContent);
8383
var reseponseJson = await result.Content.ReadAsStringAsync();

src/c#/GeneralUpdate.Upgrad/GeneralUpdate.Upgrad.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8-
<!--<PublishAot>true</PublishAot>
9-
<RuntimeIdentifier>win-x64</RuntimeIdentifier>-->
8+
<PublishAot>true</PublishAot>
9+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1010
</PropertyGroup>
1111

1212
<ItemGroup>

0 commit comments

Comments
 (0)