Skip to content

fix: 修复实例列表缓存无法读取的问题#2808

Merged
SALTWOOD merged 1 commit into
devfrom
fix/instance-list-cache-datetime
May 8, 2026
Merged

fix: 修复实例列表缓存无法读取的问题#2808
SALTWOOD merged 1 commit into
devfrom
fix/instance-list-cache-datetime

Conversation

@Big-Cake-jpg
Copy link
Copy Markdown
Member

@Big-Cake-jpg Big-Cake-jpg commented May 8, 2026

Summary by Sourcery

错误修复:

  • 修正 Minecraft 实例的发布时间反序列化问题,以便可以正确读取缓存的实例数据。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Correct release time deserialization for Minecraft instances so cached instance data can be read properly.

@Big-Cake-jpg Big-Cake-jpg requested a review from a team May 8, 2026 11:45
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: XS PR 大小评估:微型 labels May 8, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 8, 2026

审查者指南(在小型 PR 上折叠)

审查者指南

通过将存储的字符串值解析为 DateTime,而不是依赖动态类型转换,修复了缓存实例列表发布时间的读取。

更新后实例缓存发布时间加载的时序图

sequenceDiagram
    participant ModMinecraft
    participant InstanceConfig
    participant McInstance

    ModMinecraft->>InstanceConfig: get ReleaseTime[pathInstance]
    InstanceConfig-->>ModMinecraft: string releaseTimeValue
    ModMinecraft->>ModMinecraft: DateTime.Parse(releaseTimeValue)
    ModMinecraft->>McInstance: set ReleaseTime(parsedDateTime)
Loading

从缓存更新发布时间赋值的类图

classDiagram
    class ModMinecraft {
        +InitMcInstanceList() Dictionary~McInstanceCardType, List~McInstance~~
    }

    class McInstance {
        +string PathInstance
        +string Logo
        +DateTime ReleaseTime
        +McInstanceState State
    }

    class InstanceConfig {
        +Dictionary~string, string~ LogoPath
        +LogoPathConfigType LogoPathConfig
        +Dictionary~string, string~ ReleaseTime
        +ReleaseTimeConfigType ReleaseTimeConfig
        +Dictionary~string, int~ State
        +StateConfigType StateConfig
    }

    class LogoPathConfigType {
        +IsDefault(pathInstance string) bool
    }

    class ReleaseTimeConfigType {
        +IsDefault(pathInstance string) bool
    }

    class StateConfigType {
        +IsDefault(pathInstance string) bool
    }

    ModMinecraft ..> McInstance : initializes
    ModMinecraft ..> InstanceConfig : reads cached values
    ModMinecraft ..> DateTime : Parse(string)

    InstanceConfig o-- LogoPathConfigType
    InstanceConfig o-- ReleaseTimeConfigType
    InstanceConfig o-- StateConfigType

    McInstance --> McInstanceState
    McInstance --> DateTime
Loading

文件级变更

Change Details Files
修正缓存 Minecraft 实例的发布时间反序列化逻辑。
  • 将对缓存 ReleaseTime 值的动态类型转换替换为对存储配置值执行显式的 DateTime.Parse
  • 保留现有对 ReleaseTimeConfig 的条件判断,仅在存在非默认值时才进行解析
Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.cs

提示与命令

与 Sourcery 交互

  • 触发一次新的审查: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 在审查评论下回复,要求 Sourcery 从该评论创建一个 issue。你也可以直接回复 @sourcery-ai issue,由此从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 上评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 上评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 pull request 上评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 一次性解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve,将所有 Sourcery 评论标记为已解决。适用于你已经处理完所有评论且不想再看到它们的情况。
  • 一次性忽略所有 Sourcery 审查: 在 pull request 上评论 @sourcery-ai dismiss,将所有现有的 Sourcery 审查全部忽略。特别适合你想从一次全新的审查开始——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的使用体验

访问你的 控制面板 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 修改审查使用的语言。
  • 添加、删除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes reading of cached instance list release times by parsing stored string values into DateTime instead of relying on dynamic casting.

Sequence diagram for the updated instance cache release time loading

sequenceDiagram
    participant ModMinecraft
    participant InstanceConfig
    participant McInstance

    ModMinecraft->>InstanceConfig: get ReleaseTime[pathInstance]
    InstanceConfig-->>ModMinecraft: string releaseTimeValue
    ModMinecraft->>ModMinecraft: DateTime.Parse(releaseTimeValue)
    ModMinecraft->>McInstance: set ReleaseTime(parsedDateTime)
Loading

Class diagram for updated release time assignment from cache

classDiagram
    class ModMinecraft {
        +InitMcInstanceList() Dictionary~McInstanceCardType, List~McInstance~~
    }

    class McInstance {
        +string PathInstance
        +string Logo
        +DateTime ReleaseTime
        +McInstanceState State
    }

    class InstanceConfig {
        +Dictionary~string, string~ LogoPath
        +LogoPathConfigType LogoPathConfig
        +Dictionary~string, string~ ReleaseTime
        +ReleaseTimeConfigType ReleaseTimeConfig
        +Dictionary~string, int~ State
        +StateConfigType StateConfig
    }

    class LogoPathConfigType {
        +IsDefault(pathInstance string) bool
    }

    class ReleaseTimeConfigType {
        +IsDefault(pathInstance string) bool
    }

    class StateConfigType {
        +IsDefault(pathInstance string) bool
    }

    ModMinecraft ..> McInstance : initializes
    ModMinecraft ..> InstanceConfig : reads cached values
    ModMinecraft ..> DateTime : Parse(string)

    InstanceConfig o-- LogoPathConfigType
    InstanceConfig o-- ReleaseTimeConfigType
    InstanceConfig o-- StateConfigType

    McInstance --> McInstanceState
    McInstance --> DateTime
Loading

File-Level Changes

Change Details Files
Correct release time deserialization for cached Minecraft instances.
  • Replace dynamic cast of cached ReleaseTime value with explicit DateTime.Parse on the stored configuration value
  • Keep existing conditional guards on ReleaseTimeConfig to only parse when a non-default value exists
Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.cs

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我已经给出了一些总体反馈:

  • 在将 ReleaseTime 的赋值改为使用 DateTime.Parse 时,建议考虑使用 DateTime.TryParse(以及/或者指定明确的区域性和格式),以避免在缓存值缺失或格式不正确时出现潜在的运行时异常,或依赖本地化设置的解析问题。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- When changing `ReleaseTime` assignment to `DateTime.Parse`, consider using `DateTime.TryParse` (and/or specifying an explicit culture and format) to avoid potential runtime exceptions or locale-dependent parsing issues if the cached value is missing or malformed.

Sourcery 对开源项目是免费的——如果你喜欢我们的代码审查,欢迎分享给更多人 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • When changing ReleaseTime assignment to DateTime.Parse, consider using DateTime.TryParse (and/or specifying an explicit culture and format) to avoid potential runtime exceptions or locale-dependent parsing issues if the cached value is missing or malformed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When changing `ReleaseTime` assignment to `DateTime.Parse`, consider using `DateTime.TryParse` (and/or specifying an explicit culture and format) to avoid potential runtime exceptions or locale-dependent parsing issues if the cached value is missing or malformed.

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.

@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels May 8, 2026
@SALTWOOD SALTWOOD merged commit 33072c5 into dev May 8, 2026
3 checks passed
@pcl-ce-automation pcl-ce-automation Bot added 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels May 8, 2026
@SALTWOOD SALTWOOD deleted the fix/instance-list-cache-datetime branch May 8, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS PR 大小评估:微型 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants