XFEExtension.NetCore.ServerInteractive
[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.ServerInteractive.SourceGenerator/AnalyzerReleases.Unshipped.md
+2
-1
Modified
XFEExtension.NetCore.ServerInteractive.SourceGenerator/EntryPointGenerator.cs
+28
-0
Modified
XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/ServerService/ServerIpInitializer.cs
+0
-28
XFEstudio/XFEExtension.NetCore.ServerInteractive
fix: add duplicate path diagnostic XFE0012 in EntryPointGenerator; remove dead commented code in ServerIpInitializer
Agent-Logs-Url: https://github.com/XFEstudio/XFEExtension.NetCore.ServerInteractive/sessions/0bdd5cc2-db83-4424-ba4b-914b3786e270 Co-authored-by: XFEstudio <132526994+XFEstudio@users.noreply.github.com>
b7ccf5d
代码差异
3 个文件
+30
-29
@@ -13,4 +13,5 @@ XFE0007 | XFEServerInteractive | Error | ClientRequestGenerator, [Documentation]
13
13
XFE0008 | XFEServerInteractive | Error | ClientRequestGenerator, [Documentation](https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0008)
14
14
XFE0009 | XFEServerInteractive | Error | ClientRequestGenerator, [Documentation](https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0009)
15
15
XFE0010 | XFEServerInteractive | Error | ClientRequestGenerator, [Documentation](https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0010)
16
XFE0011 | XFEServerInteractive | Error | ClientRequestGenerator, [Documentation](https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0011)
16
XFE0011 | XFEServerInteractive | Error | ClientRequestGenerator, [Documentation](https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0011)
17
XFE0012 | XFEServerInteractive | Error | EntryPointGenerator, [Documentation](https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0012)
@@ -53,6 +53,15 @@ public class EntryPointGenerator : IIncrementalGenerator
53
53
helpLinkUri: "https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0006",
54
54
isEnabledByDefault: true);
55
55
56
private static readonly DiagnosticDescriptor DuplicatePathRule = new(
57
id: "XFE0012",
58
title: "EntryPoint路径重复注册",
59
messageFormat: "入口点路径'{0}'在类'{1}'中重复注册,每个路径只能对应一个处理方法",
60
category: "XFEServerInteractive",
61
defaultSeverity: DiagnosticSeverity.Error,
62
helpLinkUri: "https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFE0012",
63
isEnabledByDefault: true);
64
56
65
public void Initialize(IncrementalGeneratorInitializationContext context)
57
66
{
58
67
// 找到所有标记了EntryPointAttribute的方法
@@ -206,6 +215,25 @@ public class EntryPointGenerator : IIncrementalGenerator
206
215
var methodInfos = group.ToList();
207
216
var constraintsSuffix = string.IsNullOrEmpty(typeConstraints) ? "" : $" {typeConstraints}";
208
217
218
// 检查重复路径(路径相同的任意两个方法都报错,无论同步/异步)
219
var hasDuplicateError = false;
220
var seenPaths = new HashSet<string>();
221
foreach (var method in methodInfos)
222
{
223
if (!seenPaths.Add(method.Path))
224
{
225
context.ReportDiagnostic(Diagnostic.Create(
226
DuplicatePathRule,
227
method.MethodLocation.ToLocation(),
228
method.Path,
229
className));
230
hasDuplicateError = true;
231
}
232
}
233
234
if (hasDuplicateError)
235
continue;
236
209
237
var sourceBuilder = new StringBuilder();
210
238
sourceBuilder.AppendLine($@"// <auto-generated/>
211
239
#nullable enable
@@ -10,32 +10,4 @@ public class ServerIPInitializer : ServerInitializerServiceBase
10
10
{
11
11
/// <inheritdoc/>
12
12
public override void Initialize() { }
13
//private static int s_nextDefaultPort = 3300;
14
///// <inheritdoc/>
15
//public override void Initialize()
16
//{
17
// ServerBaseProfile.SaveProfile();
18
// foreach (var serverCoreService in XFEServer.ServerCoreProcessService.ServerCoreServiceList)
19
// {
20
// ServerBaseProfile.ServerLastBindingAddressDictionary.TryAdd(serverCoreService.ServerCoreName, $"http://localhost:{s_nextDefaultPort++}/");
21
// if (!ServerBaseProfile.ServerLastBindingAddressDictionary.TryGetValue(serverCoreService.ServerCoreName, out var ipAddress)) continue;
22
// Console.WriteLine($"正在设置服务器:{serverCoreService.ServerCoreName}");
23
// Console.WriteLine($"是否绑定IP:{ipAddress}?(Y/N)");
24
// var key = Console.ReadKey();
25
// Console.WriteLine(key.Key.ToString());
26
// if (key.Key == ConsoleKey.N)
27
// {
28
// ipAddress = string.Empty;
29
// while (ipAddress.IsNullOrWhiteSpace())
30
// {
31
// XFEConsole.XFEConsole.CurrentConsoleTextWriter?.OriginalTextWriter.Write("请输入绑定的IP:");
32
// ipAddress = Console.ReadLine();
33
// }
34
// ServerBaseProfile.ServerLastBindingAddressDictionary[serverCoreService.ServerCoreName] = ipAddress;
35
// }
36
// serverCoreService.BindingIPAddressList = [];
37
// Console.WriteLine($"服务器{serverCoreService.ServerCoreName}设置完成!IP为:{ipAddress}");
38
// }
39
// ServerBaseProfile.SaveProfile();
40
//}
41
13
}