Skip to content

Commit d7846bd

Browse files
committed
AOT适配
1 parent dc43bd6 commit d7846bd

File tree

11 files changed

+28
-21
lines changed

11 files changed

+28
-21
lines changed

src/c#/GeneralUpdate.Bowl/Bowl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Runtime.InteropServices;
44
using System.Text.Json;
5+
using GeneralUpdate.Bowl.Internal;
56
using GeneralUpdate.Bowl.Strategys;
67
using GeneralUpdate.Common.AOT.JsonContext;
78
using GeneralUpdate.Common.Shared.Object;

src/c#/GeneralUpdate.Bowl/Strategys/Crash.cs renamed to src/c#/GeneralUpdate.Bowl/Internal/Crash.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System.Collections.Generic;
2+
using GeneralUpdate.Bowl.Strategys;
23

3-
namespace GeneralUpdate.Bowl.Strategys;
4+
namespace GeneralUpdate.Bowl.Internal;
45

5-
public class Crash
6+
internal class Crash
67
{
78
public MonitorParameter Parameter { get; set; }
89

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace GeneralUpdate.Bowl.Internal;
4+
5+
[JsonSerializable(typeof(Crash))]
6+
internal partial class CrashJsonContext : JsonSerializerContext;

src/c#/GeneralUpdate.Bowl/Strategys/LinuxSystem.cs renamed to src/c#/GeneralUpdate.Bowl/Internal/LinuxSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GeneralUpdate.Bowl.Strategys;
1+
namespace GeneralUpdate.Bowl.Internal;
22

33
internal class LinuxSystem
44
{

src/c#/GeneralUpdate.Bowl/Strategys/AbstractStrategy.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Diagnostics;
43
using System.IO;
5-
using GeneralUpdate.Common.FileBasic;
64

75
namespace GeneralUpdate.Bowl.Strategys;
86

9-
public abstract class AbstractStrategy : IStrategy
7+
internal abstract class AbstractStrategy : IStrategy
108
{
119
protected MonitorParameter _parameter;
1210
protected List<string> OutputList = new ();

src/c#/GeneralUpdate.Bowl/Strategys/IStrategy.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
namespace GeneralUpdate.Bowl.Strategys;
1+
using GeneralUpdate.Bowl.Internal;
22

3-
public interface IStrategy
3+
namespace GeneralUpdate.Bowl.Strategys;
4+
5+
internal interface IStrategy
46
{
57
void Launch();
68

src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
using System.Diagnostics;
44
using System.IO;
55
using System.Linq;
6+
using GeneralUpdate.Bowl.Internal;
67

78
namespace GeneralUpdate.Bowl.Strategys;
89

9-
public class LinuxStrategy : AbstractStrategy
10+
internal class LinuxStrategy : AbstractStrategy
1011
{
1112
/*procdump-3.3.0-0.cm2.x86_64.rpm:
1213
Compatible Systems: This RPM package may be suitable for certain CentOS or RHEL-based derivatives, specifically the CM2 version. CM2 typically refers to ClearOS 7.x or similar community-maintained versions.

src/c#/GeneralUpdate.Bowl/Strategys/WindowStrategy.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
using System.Diagnostics;
44
using System.IO;
55
using System.Runtime.InteropServices;
6+
using GeneralUpdate.Bowl.Internal;
67
using GeneralUpdate.Common.FileBasic;
78

89
namespace GeneralUpdate.Bowl.Strategys;
910

10-
public class WindowStrategy : AbstractStrategy
11+
internal class WindowStrategy : AbstractStrategy
1112
{
1213
private const string WorkModel = "Upgrade";
1314
private string? _applicationsDirectory;
@@ -62,7 +63,7 @@ private void CreateCrash()
6263
ProcdumpOutPutLines = OutputList
6364
};
6465
var failJsonPath = Path.Combine(_parameter.FailDirectory, _parameter.FailFileName);
65-
GeneralFileManager.CreateJson(failJsonPath, crash);
66+
GeneralFileManager.CreateJson(failJsonPath, crash, CrashJsonContext.Default.Crash);
6667
}
6768

6869
/// <summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ await Task.Run(() =>
4848
if (!File.Exists(appPath))
4949
throw new Exception($"The application does not exist {upgradeAppName} !");
5050

51-
var json = JsonSerializer.Serialize(configGlobalConfigInfo);
51+
var json = JsonSerializer.Serialize(configGlobalConfigInfo, GlobalConfigInfoOSSJsonContext.Default.GlobalConfigInfoOSS);
5252
Environment.SetEnvironmentVariable("GlobalConfigInfoOSS", json, EnvironmentVariableTarget.User);
5353
Process.Start(appPath);
5454
}

src/c#/GeneralUpdate.Common/FileBasic/GeneralFileManager.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@ public ComparisonResult Compare(string leftDir, string rightDir)
5050
return ComparisonResult;
5151
}
5252

53-
public static void CreateJson<T>(string targetPath, T obj) where T : class
53+
public static void CreateJson<T>(string targetPath, T obj, JsonTypeInfo<T>? typeInfo = null) where T : class
5454
{
5555
var folderPath = Path.GetDirectoryName(targetPath) ??
5656
throw new ArgumentException("invalid path", nameof(targetPath));
57+
5758
if (!Directory.Exists(folderPath))
58-
{
5959
Directory.CreateDirectory(folderPath);
60-
}
61-
62-
var jsonString = JsonSerializer.Serialize(obj);
60+
61+
var jsonString = typeInfo!= null ? JsonSerializer.Serialize(obj, typeInfo) : JsonSerializer.Serialize(obj);
6362
File.WriteAllText(targetPath, jsonString);
6463
}
6564

0 commit comments

Comments
 (0)