Skip to content

Commit ec81d8e

Browse files
committed
Add AOT support
1 parent d5910da commit ec81d8e

File tree

22 files changed

+177
-73
lines changed

22 files changed

+177
-73
lines changed

Quick.Protocol.Pipeline/QpPipelineClientOptions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4-
using System.Text;
4+
using System.Text.Json.Serialization;
55

66
namespace Quick.Protocol.Pipeline
77
{
8+
[JsonSerializable(typeof(QpPipelineClientOptions))]
9+
internal partial class QpPipelineClientOptionsOptionsSerializerContext : JsonSerializerContext { }
10+
811
public class QpPipelineClientOptions : QpClientOptions
912
{
13+
protected override JsonSerializerContext JsonSerializerContext => QpPipelineClientOptionsOptionsSerializerContext.Default;
14+
1015
public const string URI_SCHEMA = "qp.pipe";
1116

1217
[Category("常用")]

Quick.Protocol.Pipeline/QpPipelineServerOptions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
2+
using System.Text.Json.Serialization;
43

54
namespace Quick.Protocol.Pipeline
65
{
6+
[JsonSerializable(typeof(QpPipelineServerOptions))]
7+
internal partial class QpPipelineServerOptionsOptionsSerializerContext : JsonSerializerContext { }
8+
79
public class QpPipelineServerOptions : QpServerOptions
810
{
11+
protected override JsonSerializerContext JsonSerializerContext => QpPipelineServerOptionsOptionsSerializerContext.Default;
12+
913
public string PipeName { get; set; }
1014

1115
public override void Check()

Quick.Protocol.SerialPort/QpSerialPortClientOptions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.IO.Ports;
5-
using System.Text;
5+
using System.Text.Json.Serialization;
66

77
namespace Quick.Protocol.SerialPort
88
{
9+
[JsonSerializable(typeof(QpSerialPortClientOptions))]
10+
internal partial class QpSerialPortClientOptionsOptionsSerializerContext : JsonSerializerContext { }
11+
912
public class QpSerialPortClientOptions : QpClientOptions
1013
{
14+
protected override JsonSerializerContext JsonSerializerContext => QpSerialPortClientOptionsOptionsSerializerContext.Default;
15+
1116
public const string URI_SCHEMA = "qp.serial";
1217
/// <summary>
1318
/// 端口名称

Quick.Protocol.SerialPort/QpSerialPortServerOptions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO.Ports;
4-
using System.Text;
3+
using System.Text.Json.Serialization;
54

65
namespace Quick.Protocol.SerialPort
76
{
7+
[JsonSerializable(typeof(QpSerialPortServerOptions))]
8+
internal partial class QpSerialPortServerOptionsOptionsSerializerContext : JsonSerializerContext { }
9+
810
public class QpSerialPortServerOptions : QpServerOptions
911
{
12+
protected override JsonSerializerContext JsonSerializerContext => QpSerialPortServerOptionsOptionsSerializerContext.Default;
13+
1014
/// <summary>
1115
/// 端口名称
1216
/// </summary>

Quick.Protocol.Tcp/QpTcpClientOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.Text;
5+
using System.Text.Json.Serialization;
56

67
namespace Quick.Protocol.Tcp
78
{
9+
[JsonSerializable(typeof(QpTcpClientOptions))]
10+
internal partial class QpTcpClientOptionsOptionsSerializerContext : JsonSerializerContext { }
11+
812
public class QpTcpClientOptions : QpClientOptions
913
{
14+
protected override JsonSerializerContext JsonSerializerContext => QpTcpClientOptionsOptionsSerializerContext.Default;
15+
1016
public const string URI_SCHEMA = "qp.tcp";
1117
/// <summary>
1218
/// 主机

Quick.Protocol.Tcp/QpTcpServerOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
namespace Quick.Protocol.Tcp
66
{
7+
[JsonSerializable(typeof(QpTcpServerOptions))]
8+
internal partial class QpTcpServerOptionsOptionsSerializerContext : JsonSerializerContext { }
9+
710
public class QpTcpServerOptions : QpServerOptions
811
{
12+
protected override JsonSerializerContext JsonSerializerContext => QpTcpServerOptionsOptionsSerializerContext.Default;
913
/// <summary>
1014
/// IP地址
1115
/// </summary>

Quick.Protocol.WebSocket.Client/QpWebSocketClientOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.Text;
5+
using System.Text.Json.Serialization;
56

67
namespace Quick.Protocol.WebSocket.Client
78
{
9+
[JsonSerializable(typeof(QpWebSocketClientOptions))]
10+
internal partial class QpWebSocketClientOptionsSerializerContext : JsonSerializerContext { }
11+
812
public class QpWebSocketClientOptions : QpClientOptions
913
{
14+
protected override JsonSerializerContext JsonSerializerContext => QpWebSocketClientOptionsSerializerContext.Default;
15+
1016
public const string URI_SCHEMA_WS = "qp.ws";
1117
public const string URI_SCHEMA_WSS = "qp.wss";
1218

Quick.Protocol.WebSocket.Server.AspNetCore/QpWebSocketServerOptions.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
using System.Text.Json;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Net;
5-
using System.Text;
1+
using System.Text.Json.Serialization;
62

73
namespace Quick.Protocol.WebSocket.Server.AspNetCore
84
{
5+
[JsonSerializable(typeof(QpWebSocketServerOptions))]
6+
internal partial class QpWebSocketServerOptionsSerializerContext : JsonSerializerContext { }
7+
98
public class QpWebSocketServerOptions : QpServerOptions
109
{
10+
protected override JsonSerializerContext JsonSerializerContext => QpWebSocketServerOptionsSerializerContext.Default;
11+
1112
private string _Path;
1213
/// <summary>
1314
/// WebSocket的路径

Quick.Protocol/Base.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace Quick.Protocol
1+
namespace Quick.Protocol
62
{
73
public class Base
84
{
@@ -12,15 +8,25 @@ public class Base
128
Name = "基础指令集",
139
NoticeInfos = new QpNoticeInfo[]
1410
{
15-
QpNoticeInfo.Create<Notices.PrivateNotice>()
11+
QpNoticeInfo.Create<Notices.PrivateNotice>(Notices.NoticesSerializerContext.Default)
1612
},
1713
CommandInfos = new QpCommandInfo[]
1814
{
19-
QpCommandInfo.Create(new Commands.Connect.Request()),
20-
QpCommandInfo.Create(new Commands.Authenticate.Request()),
21-
QpCommandInfo.Create(new Commands.HandShake.Request()),
22-
QpCommandInfo.Create(new Commands.PrivateCommand.Request()),
23-
QpCommandInfo.Create(new Commands.GetQpInstructions.Request()),
15+
QpCommandInfo.Create(
16+
new Commands.Connect.Request(),
17+
Commands.ConnectCommandSerializerContext.Default),
18+
QpCommandInfo.Create(
19+
new Commands.Authenticate.Request(),
20+
Commands.AuthenticateCommandSerializerContext.Default),
21+
QpCommandInfo.Create(
22+
new Commands.HandShake.Request(),
23+
Commands.HandShakeCommandSerializerContext.Default),
24+
QpCommandInfo.Create(
25+
new Commands.PrivateCommand.Request(),
26+
Commands.PrivateCommandCommandSerializerContext.Default),
27+
QpCommandInfo.Create(
28+
new Commands.GetQpInstructions.Request(),
29+
Commands.GetQpInstructionsCommandSerializerContext.Default)
2430
}
2531
};
2632
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace Quick.Protocol.Commands;
4+
5+
[JsonSerializable(typeof(Connect.Request))]
6+
[JsonSerializable(typeof(Connect.Response))]
7+
internal partial class ConnectCommandSerializerContext : JsonSerializerContext { }
8+
9+
[JsonSerializable(typeof(Authenticate.Request))]
10+
[JsonSerializable(typeof(Authenticate.Response))]
11+
internal partial class AuthenticateCommandSerializerContext : JsonSerializerContext { }
12+
13+
[JsonSerializable(typeof(HandShake.Request))]
14+
[JsonSerializable(typeof(HandShake.Response))]
15+
internal partial class HandShakeCommandSerializerContext : JsonSerializerContext { }
16+
17+
[JsonSerializable(typeof(PrivateCommand.Request))]
18+
[JsonSerializable(typeof(PrivateCommand.Response))]
19+
internal partial class PrivateCommandCommandSerializerContext : JsonSerializerContext { }
20+
21+
[JsonSerializable(typeof(GetQpInstructions.Request))]
22+
[JsonSerializable(typeof(GetQpInstructions.Response))]
23+
internal partial class GetQpInstructionsCommandSerializerContext : JsonSerializerContext { }

0 commit comments

Comments
 (0)