Skip to content

refactor: 档案重做#3061

Draft
LinQingYuu wants to merge 6 commits into
devfrom
refactor/profile
Draft

refactor: 档案重做#3061
LinQingYuu wants to merge 6 commits into
devfrom
refactor/profile

Conversation

@LinQingYuu

@LinQingYuu LinQingYuu commented Jun 7, 2026

Copy link
Copy Markdown
Member

重写档案系统,使其基于规范的 IdentityModel 而不是原先一堆问题的 ModLaunch

Resolved #17
Resolved #2867

@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: L PR 大小评估:大型 labels Jun 7, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 7, 2026

Copy link
Copy Markdown

审查者指南(Reviewer's Guide)

引入了一个新的、基于 IdentityModel 的 Minecraft 档案(profile)子系统脚手架,包括档案存储抽象、旧/新档案模型,以及 Xbox/Microsoft 身份验证辅助类型,并增加了一个由生命周期管理的 ProfileService 占位组件,用于未来的迁移/导入逻辑。

文件级变更

Change Details Files
Add lifecycle-managed ProfileService skeleton to host new and legacy profile management and migration logic.
  • 将 ProfileService 定义为一个带有 start 钩子的、按作用域(scoped)管理生命周期的组件,用于初始化档案子系统。
  • 通过通用的 ProfileJson 包装器,为新旧档案格式分别引入独立的 ProfileManagement 实例。
  • 预留档案迁移与导入方法的骨架,包括文件路径设置,以及围绕迁移检查的基础日志记录/错误处理。
PCL.Core/Minecraft/Profile/Profile/ProfileService.cs
PCL.Core/Minecraft/Profile/ProfileService.cs
Introduce generic profile management abstraction for loading, updating, and clearing profile collections.
  • 定义 IProfileManagement 接口,涵盖创建、删除、更新、从文件/字符串加载以及清空操作。
  • 提供一个通用的 ProfileManagement 实现,目前所有方法都抛出 NotImplementedException,作为新档案后端的占位实现。
PCL.Core/Minecraft/Profile/IProfileManagement.cs
PCL.Core/Minecraft/Profile/Profile/IProfileManagement.cs
PCL.Core/Minecraft/Profile/ProfileManagement.cs
PCL.Core/Minecraft/Profile/Profile/ProfileManagement.cs
Define old/new profile data models and container, including profile type enumeration.
  • 添加 OldProfile 记录类型,用于镜像旧版档案 JSON 字段,以支持迁移。
  • 添加 ProfileJson 容器,包含 LastUsed 索引和不可变的档案集合。
  • 引入 ProfileType 枚举,用于区分 Microsoft、Offline 和 Authlib 档案。
  • 添加一个预留的 Profile 类,并带有用于创建身份验证提供者的工厂方法。
PCL.Core/Minecraft/Profile/Profile/Models/OldProfile.cs
PCL.Core/Minecraft/Profile/Profile/Models/ProfileJson.cs
PCL.Core/Minecraft/Profile/Profile/Models/ProfileType.cs
PCL.Core/Minecraft/Profile/Profile/Models/Profile.cs
Add Xbox Live and Mojang authentication helper models and utilities aligned with identity-based auth flows.
  • 创建 XboxUtils,提供泛型的 AuthenticateAsync 助手,用于向 Xbox Live 或 XSTS 端点发起 POST 请求并反序列化响应。
  • 定义用于 Xbox 身份验证负载和响应的 DTO 记录/类(XboxAuthenticate、XboxProperty、XSTSProperty、XboxDisplayClaims、XboxUserHash、XboxLiveResponse)。
  • 引入与 Mojang 相关的 DTO 和工具骨架(MojangIdentityToken、MojangResponse、MojangUtils),用于后续集成到基于 Identity 的登录流程中。
  • 预留 MicrosoftProvider 类,作为未来的身份验证提供者实现。
  • 引入 IAuthenticateProvider 接口,以支持可插拔的身份验证提供者(目前其中的方法签名被注释掉)。
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/XboxUtils.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxDisplayClaims.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxLiveResponse.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/MojangIdentityToken.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/MojangResponse.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XSTSProperty.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxUserHash.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxAuthenticate.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxProperty.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/MojangUtils.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/IAuthenticateProvider.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/MicrosoftProvider.cs

与关联 Issue 的符合度评估

Issue Objective Addressed Explanation
#2869 基于标准化的 IdentityModel 实现新的档案系统(profile system),以取代现有基于 ModLaunch 的实现。 本 PR 引入了新的档案系统脚手架(ProfileService、ProfileManagement、Profile/OldProfile 模型以及与身份验证相关的类型),但核心功能尚未实现:ProfileManagement 的所有方法都抛出 NotImplementedException,Profile.CreateAuthenticateServiceProvider 返回默认值,MicrosoftProvider 为空,MojangUtils/XboxUtils 也缺少完整的流程。目前还没有真正替换旧的基于 ModLaunch 的档案处理逻辑,只是搭建了初始结构。
#2869 将现有存储的档案从旧的存档实现迁移到新的基于 IdentityModel 的系统。 ProfileService._MigrateProfile 已存在,但除路径设置和日志记录外,没有实际迁移逻辑;它既不会读取旧的 profiles.json,也不会将转换后的数据写入新的 ProfileJson/IdentityModel 格式。该方法会基于迁移标记文件提前返回,并未执行任何具体的迁移步骤。
#2869 在新的档案系统中,确保不同身份验证提供者(如 Microsoft/Xbox/Mojang)之间行为的一致性和规范(spec)兼容性。 虽然 PR 添加了若干与身份验证相关的模型和工具(XboxUtils、MojangIdentityToken、XboxAuthenticate、Xbox/XSTS 模型、MojangResponse 等),但尚无实现的端到端身份验证流程,也没有与档案系统的集成。IAuthenticateProvider 为空,MicrosoftProvider 没有逻辑,MojangUtils 仅声明常量且方法被注释,因此规范兼容、统一的提供者行为尚未落地。

可能关联的 Issue

  • #(未列出 / 新 issue):Issue 要求重做档案系统为 IdentityModel,PR 正在实现新的基于 IdentityModel 的档案系统

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the
    pull request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Original review guide in English

Reviewer's Guide

Introduces a new, identity-model-based Minecraft profile subsystem scaffold, including profile storage abstractions, old/new profile models, and Xbox/Microsoft authentication helper types, plus a lifecycle-managed ProfileService placeholder for future migration/import logic.

File-Level Changes

Change Details Files
Add lifecycle-managed ProfileService skeleton to host new and legacy profile management and migration logic.
  • Define ProfileService as a scoped lifecycle component with start hook for profile subsystem initialization.
  • Introduce separate ProfileManagement instances for new and old profile formats using generic ProfileJson wrappers.
  • Stub out profile migration and import methods, including file path setup and basic logging/error handling around migration checks.
PCL.Core/Minecraft/Profile/Profile/ProfileService.cs
PCL.Core/Minecraft/Profile/ProfileService.cs
Introduce generic profile management abstraction for loading, updating, and clearing profile collections.
  • Define IProfileManagement interface covering create, delete, update, load from file/string, and clear operations.
  • Provide a generic ProfileManagement implementation that currently throws NotImplementedException for all methods, serving as a placeholder for the new profile backend.
PCL.Core/Minecraft/Profile/IProfileManagement.cs
PCL.Core/Minecraft/Profile/Profile/IProfileManagement.cs
PCL.Core/Minecraft/Profile/ProfileManagement.cs
PCL.Core/Minecraft/Profile/Profile/ProfileManagement.cs
Define old/new profile data models and container, including profile type enumeration.
  • Add OldProfile record mirroring legacy profile JSON fields for migration.
  • Add ProfileJson container with LastUsed index and immutable profile collection.
  • Introduce ProfileType enum to distinguish Microsoft, Offline, and Authlib profiles.
  • Add a stub Profile class with a factory method for creating authentication providers.
PCL.Core/Minecraft/Profile/Profile/Models/OldProfile.cs
PCL.Core/Minecraft/Profile/Profile/Models/ProfileJson.cs
PCL.Core/Minecraft/Profile/Profile/Models/ProfileType.cs
PCL.Core/Minecraft/Profile/Profile/Models/Profile.cs
Add Xbox Live and Mojang authentication helper models and utilities aligned with identity-based auth flows.
  • Create XboxUtils with a generic AuthenticateAsync helper that posts to Xbox Live or XSTS endpoints and deserializes responses.
  • Define DTO records/classes for Xbox authentication payloads and responses (XboxAuthenticate, XboxProperty, XSTSProperty, XboxDisplayClaims, XboxUserHash, XboxLiveResponse).
  • Introduce Mojang-related DTOs and utility skeletons (MojangIdentityToken, MojangResponse, MojangUtils) for later integration into the identity-based login flow.
  • Stub MicrosoftProvider class as a future authentication provider implementation.
  • Introduce IAuthenticateProvider interface for pluggable authentication providers (currently commented-out method signature).
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/XboxUtils.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxDisplayClaims.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxLiveResponse.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/MojangIdentityToken.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/MojangResponse.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XSTSProperty.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxUserHash.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxAuthenticate.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/Models/XboxProperty.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/Utils/MojangUtils.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/IAuthenticateProvider.cs
PCL.Core/Minecraft/Profile/Profile/Autnenrication/MicrosoftProvider.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#2869 Implement a new archive (profile) system based on a standardized IdentityModel, replacing the existing ModLaunch-based implementation. The PR introduces scaffolding for a new profile system (ProfileService, ProfileManagement, Profile/OldProfile models, authentication-related types), but core functionality is unimplemented: ProfileManagement methods all throw NotImplementedException, Profile.CreateAuthenticateServiceProvider returns default, MicrosoftProvider is empty, and MojangUtils/XboxUtils lack full flows. There is no actual replacement of the old ModLaunch-based profile handling yet, just initial structure.
#2869 Migrate existing stored profiles from the old archive implementation to the new IdentityModel-based system. ProfileService._MigrateProfile is present but contains no migration logic beyond path setup and logging; it neither reads the old profiles.json nor writes converted data into the new ProfileJson/IdentityModel format. The method returns early based on a migration marker file and does not perform any concrete migration steps.
#2869 Ensure consistent, spec-compliant behavior across different authentication providers (e.g., Microsoft/Xbox/Mojang) within the new profile system. While the PR adds several authentication-related models and utilities (XboxUtils, MojangIdentityToken, XboxAuthenticate, Xbox/XSTS models, MojangResponse, etc.), there is no implemented end-to-end authentication flow or integration with profiles. IAuthenticateProvider is empty, MicrosoftProvider has no logic, and MojangUtils only declares constants with commented-out methods, so the spec-compliant, unified provider behavior is not yet realized.

Possibly linked issues

  • #(unlisted / new issue): Issue 要求重做档案系统为 IdentityModel,PR 正在实现新的基于 IdentityModel 档案系统

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@LinQingYuu LinQingYuu marked this pull request as draft June 7, 2026 06:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e42b1fb48

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@@ -0,0 +1,34 @@
namespace PCL.Core.Minecraft.Profile;

public class ProfileManagement<T>: IProfileManagement<T> where T:class

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the duplicate profile type tree

Because PCL.Core.csproj explicitly compiles **\*.cs, this nested copy is built together with the new files directly under PCL.Core/Minecraft/Profile/. That creates duplicate PCL.Core.Minecraft.Profile.ProfileManagement<T>/IProfileManagement<T> definitions and duplicate ProfileService members in the same namespace, so PCL.Core cannot build until one copy of the profile tree is removed.

Useful? React with 👍 / 👎.

Comment thread PCL.Core/Minecraft/Profile/ProfileService.cs

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 4 个问题,并给出了一些整体性的反馈:

  • ProfileServiceIProfileManagement<T>ProfileManagement<T>Minecraft/Profile/Minecraft/Profile/Profile/ 路径下都有内容相同的重复定义;建议将每种类型整合为单个文件,以避免类型重复定义和后续维护上的困惑。
  • _MigrateProfile 中,与 profileMigrateFIle 相关的逻辑似乎是反的(当 Path.Exists 返回 false 时记录“已迁移档案信息,跳过检查”),并且 profileLocation 和 try 代码块目前都未使用/为空;请修正条件并实现迁移逻辑,或者移除占位代码,以避免产生误导性的行为。
  • 若干新增类型和方法(例如 ProfileManagement<T> 的方法、MicrosoftProviderMojangUtilsProfile.CreateAuthenticateServiceProvider 等)当前为空或直接抛出 NotImplementedException;如果计划近期使用这些类型,建议至少添加最小可用的行为或清晰的 TODO 注释,以便让未来维护者明确了解其当前局限性。
提供给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- There appear to be duplicate definitions for `ProfileService`, `IProfileManagement<T>`, and `ProfileManagement<T>` under both `Minecraft/Profile/` and `Minecraft/Profile/Profile/` paths with identical content; consider consolidating to a single file per type to avoid type redefinition and future maintenance confusion.
- In `_MigrateProfile`, the logic around `profileMigrateFIle` seems inverted (logging "已迁移档案信息,跳过检查" when `Path.Exists` returns false) and both `profileLocation` and the try-block are currently unused/empty; please either correct the condition and implement the migration or remove the placeholder code to avoid misleading behavior.
- Several new types and methods (`ProfileManagement<T>` methods, `MicrosoftProvider`, `MojangUtils`, `Profile.CreateAuthenticateServiceProvider`, etc.) are currently empty or throw `NotImplementedException`; if these are intended to be used soon, consider at least adding minimal behavior or clear TODO comments so their current limitations are explicit to future maintainers.

## Individual Comments

### Comment 1
<location path="PCL.Core/Minecraft/Profile/Profile/ProfileService.cs" line_range="25-28" />
<code_context>
+    {
+        
+        var profileLocation = Path.Combine(Paths.SharedData, "profiles.json");
+        var profileMigrateFIle = Path.Combine(Paths.SharedData, "pcl.ce.migrated");
+        if (!Path.Exists(profileMigrateFIle))
+        {
+            Context.Debug("已迁移档案信息,跳过检查");
+            return;
+        }
</code_context>
<issue_to_address>
**issue (bug_risk):** The migration guard condition appears inverted relative to the log message.

The log is emitted when `!Path.Exists(profileMigrateFIle)`, i.e. when the marker file is missing, which implies migration has not run yet. Usually you’d only skip migration when the marker file exists. Please either invert the condition or adjust the log so the marker file consistently represents “migration already done.”
</issue_to_address>

### Comment 2
<location path="PCL.Core/Minecraft/Profile/Profile/ProfileService.cs" line_range="17-12" />
<code_context>
+    private static ProfileManagement<ProfileJson<Models.OldProfile>> _oldProfileProvider = new();
+
+    [LifecycleStart]
+    private static async Task _Start()
+    {
+    }
+
</code_context>
<issue_to_address>
**suggestion:** Avoid `async` on `_Start` since it currently does not `await` anything.

This empty `async` method will produce a compiler warning and allocate an unnecessary async state machine. Either drop `async` and return `Task.CompletedTask`, or add the actual asynchronous work so `async` is justified.

Suggested implementation:

```csharp
    [LifecycleStart]
    private static Task _Start()

```

```csharp
    private static Task _Start()
    {
        return Task.CompletedTask;
    }

```

If `using System.Threading.Tasks;` is not already present at the top of `ProfileService.cs`, it should be added so that `Task` and `Task.CompletedTask` resolve correctly.
</issue_to_address>

### Comment 3
<location path="PCL.Core/Minecraft/Profile/ProfileManagement.cs" line_range="3-4" />
<code_context>
+namespace PCL.Core.Minecraft.Profile;
+
+public class ProfileManagement<T>: IProfileManagement<T> where T:class
+{
+    public T Create()
+    {
</code_context>
<issue_to_address>
**issue (bug_risk):** There are duplicate `ProfileManagement<T>` definitions in the same namespace.

This class also exists in `Profile/ProfileManagement.cs` under the same `PCL.Core.Minecraft.Profile` namespace, which will cause a type redefinition compile error. Please remove one definition or change the namespace so only one `ProfileManagement<T>` exists in this namespace.
</issue_to_address>

### Comment 4
<location path="PCL.Core/Minecraft/Profile/IProfileManagement.cs" line_range="3-4" />
<code_context>
+namespace PCL.Core.Minecraft.Profile;
+
+public interface IProfileManagement<T>
+{
+    /// <summary>
+    /// 创建一个档案
</code_context>
<issue_to_address>
**issue (bug_risk):** There are duplicate `IProfileManagement<T>` interfaces in the same namespace.

`IProfileManagement<T>` is defined in both `Minecraft/Profile/IProfileManagement.cs` and `Minecraft/Profile/Profile/IProfileManagement.cs` under the same namespace with identical members, which creates a duplicate type. Please consolidate to a single definition or adjust namespaces so only one is visible to consumers.
</issue_to_address>

Sourcery 对开源项目免费——如果你喜欢我们的代码审查,请考虑分享它们 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈不断改进审查质量。
Original comment in English

Hey - I've found 4 issues, and left some high level feedback:

  • There appear to be duplicate definitions for ProfileService, IProfileManagement<T>, and ProfileManagement<T> under both Minecraft/Profile/ and Minecraft/Profile/Profile/ paths with identical content; consider consolidating to a single file per type to avoid type redefinition and future maintenance confusion.
  • In _MigrateProfile, the logic around profileMigrateFIle seems inverted (logging "已迁移档案信息,跳过检查" when Path.Exists returns false) and both profileLocation and the try-block are currently unused/empty; please either correct the condition and implement the migration or remove the placeholder code to avoid misleading behavior.
  • Several new types and methods (ProfileManagement<T> methods, MicrosoftProvider, MojangUtils, Profile.CreateAuthenticateServiceProvider, etc.) are currently empty or throw NotImplementedException; if these are intended to be used soon, consider at least adding minimal behavior or clear TODO comments so their current limitations are explicit to future maintainers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There appear to be duplicate definitions for `ProfileService`, `IProfileManagement<T>`, and `ProfileManagement<T>` under both `Minecraft/Profile/` and `Minecraft/Profile/Profile/` paths with identical content; consider consolidating to a single file per type to avoid type redefinition and future maintenance confusion.
- In `_MigrateProfile`, the logic around `profileMigrateFIle` seems inverted (logging "已迁移档案信息,跳过检查" when `Path.Exists` returns false) and both `profileLocation` and the try-block are currently unused/empty; please either correct the condition and implement the migration or remove the placeholder code to avoid misleading behavior.
- Several new types and methods (`ProfileManagement<T>` methods, `MicrosoftProvider`, `MojangUtils`, `Profile.CreateAuthenticateServiceProvider`, etc.) are currently empty or throw `NotImplementedException`; if these are intended to be used soon, consider at least adding minimal behavior or clear TODO comments so their current limitations are explicit to future maintainers.

## Individual Comments

### Comment 1
<location path="PCL.Core/Minecraft/Profile/Profile/ProfileService.cs" line_range="25-28" />
<code_context>
+    {
+        
+        var profileLocation = Path.Combine(Paths.SharedData, "profiles.json");
+        var profileMigrateFIle = Path.Combine(Paths.SharedData, "pcl.ce.migrated");
+        if (!Path.Exists(profileMigrateFIle))
+        {
+            Context.Debug("已迁移档案信息,跳过检查");
+            return;
+        }
</code_context>
<issue_to_address>
**issue (bug_risk):** The migration guard condition appears inverted relative to the log message.

The log is emitted when `!Path.Exists(profileMigrateFIle)`, i.e. when the marker file is missing, which implies migration has not run yet. Usually you’d only skip migration when the marker file exists. Please either invert the condition or adjust the log so the marker file consistently represents “migration already done.”
</issue_to_address>

### Comment 2
<location path="PCL.Core/Minecraft/Profile/Profile/ProfileService.cs" line_range="17-12" />
<code_context>
+    private static ProfileManagement<ProfileJson<Models.OldProfile>> _oldProfileProvider = new();
+
+    [LifecycleStart]
+    private static async Task _Start()
+    {
+    }
+
</code_context>
<issue_to_address>
**suggestion:** Avoid `async` on `_Start` since it currently does not `await` anything.

This empty `async` method will produce a compiler warning and allocate an unnecessary async state machine. Either drop `async` and return `Task.CompletedTask`, or add the actual asynchronous work so `async` is justified.

Suggested implementation:

```csharp
    [LifecycleStart]
    private static Task _Start()

```

```csharp
    private static Task _Start()
    {
        return Task.CompletedTask;
    }

```

If `using System.Threading.Tasks;` is not already present at the top of `ProfileService.cs`, it should be added so that `Task` and `Task.CompletedTask` resolve correctly.
</issue_to_address>

### Comment 3
<location path="PCL.Core/Minecraft/Profile/ProfileManagement.cs" line_range="3-4" />
<code_context>
+namespace PCL.Core.Minecraft.Profile;
+
+public class ProfileManagement<T>: IProfileManagement<T> where T:class
+{
+    public T Create()
+    {
</code_context>
<issue_to_address>
**issue (bug_risk):** There are duplicate `ProfileManagement<T>` definitions in the same namespace.

This class also exists in `Profile/ProfileManagement.cs` under the same `PCL.Core.Minecraft.Profile` namespace, which will cause a type redefinition compile error. Please remove one definition or change the namespace so only one `ProfileManagement<T>` exists in this namespace.
</issue_to_address>

### Comment 4
<location path="PCL.Core/Minecraft/Profile/IProfileManagement.cs" line_range="3-4" />
<code_context>
+namespace PCL.Core.Minecraft.Profile;
+
+public interface IProfileManagement<T>
+{
+    /// <summary>
+    /// 创建一个档案
</code_context>
<issue_to_address>
**issue (bug_risk):** There are duplicate `IProfileManagement<T>` interfaces in the same namespace.

`IProfileManagement<T>` is defined in both `Minecraft/Profile/IProfileManagement.cs` and `Minecraft/Profile/Profile/IProfileManagement.cs` under the same namespace with identical members, which creates a duplicate type. Please consolidate to a single definition or adjust namespaces so only one is visible to consumers.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +25 to +28
var profileMigrateFIle = Path.Combine(Paths.SharedData, "pcl.ce.migrated");
if (!Path.Exists(profileMigrateFIle))
{
Context.Debug("已迁移档案信息,跳过检查");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): 迁移保护条件相对于日志信息来说似乎被写反了。

当前日志是在 !Path.Exists(profileMigrateFIle) 时输出的,也就是标记文件不存在时,这通常意味着迁移尚未执行。一般情况下,只有在标记文件存在时才会跳过迁移。请反转该条件,或调整日志内容,以确保该标记文件始终明确表示“迁移已完成”。

Original comment in English

issue (bug_risk): The migration guard condition appears inverted relative to the log message.

The log is emitted when !Path.Exists(profileMigrateFIle), i.e. when the marker file is missing, which implies migration has not run yet. Usually you’d only skip migration when the marker file exists. Please either invert the condition or adjust the log so the marker file consistently represents “migration already done.”


[LifecycleScope("profile", "档案服务")]
public partial class ProfileService
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: 避免在 _Start 上使用 async,因为当前方法内部没有任何 await 调用。

这个空的 async 方法会产生编译器警告,并且会生成一个不必要的异步状态机。可以选择去掉 async 并返回 Task.CompletedTask,或者在其中加入实际的异步逻辑,使 async 变得合理。

建议实现方式:

    [LifecycleStart]
    private static Task _Start()
    private static Task _Start()
    {
        return Task.CompletedTask;
    }

如果 ProfileService.cs 顶部尚未包含 using System.Threading.Tasks;,请添加它,以确保 TaskTask.CompletedTask 能正确解析。

Original comment in English

suggestion: Avoid async on _Start since it currently does not await anything.

This empty async method will produce a compiler warning and allocate an unnecessary async state machine. Either drop async and return Task.CompletedTask, or add the actual asynchronous work so async is justified.

Suggested implementation:

    [LifecycleStart]
    private static Task _Start()
    private static Task _Start()
    {
        return Task.CompletedTask;
    }

If using System.Threading.Tasks; is not already present at the top of ProfileService.cs, it should be added so that Task and Task.CompletedTask resolve correctly.

Comment thread PCL.Core/Minecraft/Profile/ProfileManagement.cs Outdated
Comment thread PCL.Core/Minecraft/Profile/IProfileManagement.cs
@pcl-ce-automation pcl-ce-automation Bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 size: XXL PR 大小评估:巨型 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: L PR 大小评估:大型 labels Jun 9, 2026
@PCL-Community PCL-Community deleted a comment from MoYuan-CN Jun 16, 2026
LinQingYuu and others added 6 commits June 19, 2026 03:35
# Conflicts:
#	PCL.Core/Minecraft/IdentityModel/Extensions/JsonWebToken/JsonWebKeys.cs
#	PCL.Core/Minecraft/IdentityModel/Extensions/JsonWebToken/JsonWebToken.cs
#	PCL.Core/Minecraft/IdentityModel/Extensions/OpenId/OpenIdClient.cs
#	PCL.Core/Minecraft/IdentityModel/Extensions/OpenId/OpenIdOptions.cs
#	PCL.Core/Minecraft/IdentityModel/Extensions/YggdrasilConnect/YggdrasilClient.cs
#	PCL.Core/Minecraft/IdentityModel/Extensions/YggdrasilConnect/YggdrasilOptions.cs
#	PCL.Core/Minecraft/IdentityModel/IdentityModelException.cs
#	PCL.Core/Minecraft/IdentityModel/Yggdrasil/Client.cs
[SKIP CI]
[SKIP CI]
@pcl-ce-automation pcl-ce-automation Bot added size: XL PR 大小评估:超大型 and removed size: XXL PR 大小评估:巨型 labels Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XL PR 大小评估:超大型 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中

Projects

None yet

Development

Successfully merging this pull request may close these issues.

同步上游的正版令牌获取机制 [Feature] 支持 Yggdrasil Connect

1 participant