目标:XFEExtension.NetCore.ServerInteractive
代码:XFE0012
级别:❌️ 错误
描述:EntryPoint路径重复注册,同一路径在同一类中只能对应一个处理方法。
在同一个服务类内,生成器会收集所有 [EntryPoint] 的路径并进行唯一性校验。
如果两个或多个方法(无论同步 void 还是异步 Task)使用了相同路径,生成器无法确定该路径最终应绑定哪个方法,因此会触发该错误。
确保同一类中每个 [EntryPoint("...")] 的路径唯一。
using System.Threading.Tasks;
using XFEExtension.NetCore.ServerInteractive.Attributes;
namespace Demo;
public partial class UserEntryService : ServerCoreStandardService
{
// ❌ 错误:路径重复
[EntryPoint("v1/user/get")]
public void GetUserSync()
{
}
[EntryPoint("v1/user/get")]
public Task GetUserAsync()
{
return Task.CompletedTask;
}
}
using System.Threading.Tasks;
using XFEExtension.NetCore.ServerInteractive.Attributes;
namespace Demo;
public partial class UserEntryService : ServerCoreStandardService
{
// ✅ 正确:路径唯一
[EntryPoint("v1/user/get")]
public void GetUserSync()
{
}
[EntryPoint("v1/user/get-async")]
public Task GetUserAsync()
{
return Task.CompletedTask;
}
}
using System.Threading.Tasks;
using XFEExtension.NetCore.ServerInteractive.Attributes;
namespace Demo;
public partial class UserEntryService : ServerCoreStandardService
{
// ✅ 另一种正确做法:合并为单一入口
[EntryPoint("v1/user/get")]
public Task GetUser()
{
// 在这里统一处理同步/异步逻辑
return Task.CompletedTask;
}
}