Skip to content

refactor: 使用配置系统全面取代 ModBase.Setup 并移除部分 VB.CompilerServices#2866

Merged
LuLu-ling merged 7 commits into
devfrom
refactor/ModBase-Setup
May 22, 2026
Merged

refactor: 使用配置系统全面取代 ModBase.Setup 并移除部分 VB.CompilerServices#2866
LuLu-ling merged 7 commits into
devfrom
refactor/ModBase-Setup

Conversation

@LuLu-ling
Copy link
Copy Markdown
Member

@LuLu-ling LuLu-ling commented May 20, 2026

Partly Generated with DeepSeek-V4-Pro

Sourcery 总结

在启动器 UI、实例设置和 Minecraft 模块中,用强类型配置 API 替换遗留的 ModBase.Setup 用法,同时简化 VB 兼容性辅助方法,并使迁移逻辑和提示逻辑与新的配置/状态布局保持一致。

Bug 修复:

  • 当已存储的下载镜像模式配置值超出范围时,回退到“平衡”策略,防止出现无效的下载镜像模式配置。
  • 在事件处理和参数替换中处理加密或缺失的配置键时,通过在读写前检查配置项元数据,避免发生崩溃。

增强改进:

  • 在启动流程、下载逻辑、配置文件和 Minecraft 实例管理中,针对全局和每实例设置使用强类型的 Config/ConfigService 属性,而不是使用 ModBase.Setup
  • 通过基于标签的 setter 将设置 UI 页面(启动器、游戏管理、游戏关联、UI、启动器杂项、实例设置)直接连接到配置对象上,移除基于通用键的 get/set 管道。
  • 通过移除 Microsoft.VisualBasic.CompilerServices 中的运算符和 Conversions,改用原生 C# API 来简化版本和字符串比较、数值解析以及条件检查。
  • 调整迁移路径(例如实例隔离、模组命名、配置文件迁移、资源校验标志)以及提示/可见性标志,使其依赖新的配置元数据和状态容器。
  • 使用枚举和结构化配置,而不是“魔法数字”(整型常量),来优化启动器在窗口模式、进程优先级、渲染器选择、JVM 参数以及音乐/背景处理方面的行为。
Original summary in English

Summary by Sourcery

Replace legacy ModBase.Setup usage with strongly-typed configuration APIs across launcher UI, instance settings, and Minecraft modules, while simplifying VB compatibility helpers and aligning migration and hint logic with the new config/state layout.

Bug Fixes:

  • Prevent invalid download mirror mode configuration by falling back to a balanced strategy when the stored value is out of range.
  • Avoid crashes when handling encrypted or missing config keys in event handling and argument replacement by checking config item metadata before reading or writing.

Enhancements:

  • Use strongly-typed Config/ConfigService properties for global and per-instance settings instead of ModBase.Setup in launch flow, download logic, profiles, and Minecraft instance management.
  • Wire setup UI pages (launcher, game manage, game link, UI, launcher misc, instance setup) directly to config objects via tag-based setters, removing generic key-based get/set plumbing.
  • Simplify version and string comparison, numeric parsing, and condition checks by removing Microsoft.VisualBasic.CompilerServices operators and Conversions in favor of native C# APIs.
  • Adjust migration paths (e.g., instance isolation, mod naming, profile migration, asset-verify flags) and hint/visibility flags to rely on new config metadata and state containers.
  • Refine launcher behavior around window mode, process priority, renderer selection, JVM args, and music/background handling using enums and structured config instead of magic integers.
Original summary in English

Sourcery 总结

在启动器 UI、实例设置和 Minecraft 模块中,用强类型配置 API 替换遗留的 ModBase.Setup 用法,同时简化 VB 兼容性辅助方法,并使迁移逻辑和提示逻辑与新的配置/状态布局保持一致。

Bug 修复:

  • 当已存储的下载镜像模式配置值超出范围时,回退到“平衡”策略,防止出现无效的下载镜像模式配置。
  • 在事件处理和参数替换中处理加密或缺失的配置键时,通过在读写前检查配置项元数据,避免发生崩溃。

增强改进:

  • 在启动流程、下载逻辑、配置文件和 Minecraft 实例管理中,针对全局和每实例设置使用强类型的 Config/ConfigService 属性,而不是使用 ModBase.Setup
  • 通过基于标签的 setter 将设置 UI 页面(启动器、游戏管理、游戏关联、UI、启动器杂项、实例设置)直接连接到配置对象上,移除基于通用键的 get/set 管道。
  • 通过移除 Microsoft.VisualBasic.CompilerServices 中的运算符和 Conversions,改用原生 C# API 来简化版本和字符串比较、数值解析以及条件检查。
  • 调整迁移路径(例如实例隔离、模组命名、配置文件迁移、资源校验标志)以及提示/可见性标志,使其依赖新的配置元数据和状态容器。
  • 使用枚举和结构化配置,而不是“魔法数字”(整型常量),来优化启动器在窗口模式、进程优先级、渲染器选择、JVM 参数以及音乐/背景处理方面的行为。
Original summary in English

Summary by Sourcery

Replace legacy ModBase.Setup usage with strongly-typed configuration APIs across launcher UI, instance settings, and Minecraft modules, while simplifying VB compatibility helpers and aligning migration and hint logic with the new config/state layout.

Bug Fixes:

  • Prevent invalid download mirror mode configuration by falling back to a balanced strategy when the stored value is out of range.
  • Avoid crashes when handling encrypted or missing config keys in event handling and argument replacement by checking config item metadata before reading or writing.

Enhancements:

  • Use strongly-typed Config/ConfigService properties for global and per-instance settings instead of ModBase.Setup in launch flow, download logic, profiles, and Minecraft instance management.
  • Wire setup UI pages (launcher, game manage, game link, UI, launcher misc, instance setup) directly to config objects via tag-based setters, removing generic key-based get/set plumbing.
  • Simplify version and string comparison, numeric parsing, and condition checks by removing Microsoft.VisualBasic.CompilerServices operators and Conversions in favor of native C# APIs.
  • Adjust migration paths (e.g., instance isolation, mod naming, profile migration, asset-verify flags) and hint/visibility flags to rely on new config metadata and state containers.
  • Refine launcher behavior around window mode, process priority, renderer selection, JVM args, and music/background handling using enums and structured config instead of magic integers.

增强内容:

  • 在 UI 页面、事件处理和 Minecraft 模块中,用通过 Config / ConfigService 进行的强类型配置访问(包括对实例级设置的支持),替换对 ModBase.Setup 的直接 get/set/reset 调用。
  • 引入集中化的辅助方法和保护机制用于读取和写入配置值(例如 setup 值解析器、加密设置保护),并更新迁移逻辑以使用配置元数据(IsDefault / Reset / DefaultValue)。
  • 清理已废弃的被注释页面声明,并将提示/可见性检查与基于新配置的状态标记对齐。
Original summary in English

Sourcery 总结

在启动器 UI、实例设置和 Minecraft 模块中,用强类型配置 API 替换遗留的 ModBase.Setup 用法,同时简化 VB 兼容性辅助方法,并使迁移逻辑和提示逻辑与新的配置/状态布局保持一致。

Bug 修复:

  • 当已存储的下载镜像模式配置值超出范围时,回退到“平衡”策略,防止出现无效的下载镜像模式配置。
  • 在事件处理和参数替换中处理加密或缺失的配置键时,通过在读写前检查配置项元数据,避免发生崩溃。

增强改进:

  • 在启动流程、下载逻辑、配置文件和 Minecraft 实例管理中,针对全局和每实例设置使用强类型的 Config/ConfigService 属性,而不是使用 ModBase.Setup
  • 通过基于标签的 setter 将设置 UI 页面(启动器、游戏管理、游戏关联、UI、启动器杂项、实例设置)直接连接到配置对象上,移除基于通用键的 get/set 管道。
  • 通过移除 Microsoft.VisualBasic.CompilerServices 中的运算符和 Conversions,改用原生 C# API 来简化版本和字符串比较、数值解析以及条件检查。
  • 调整迁移路径(例如实例隔离、模组命名、配置文件迁移、资源校验标志)以及提示/可见性标志,使其依赖新的配置元数据和状态容器。
  • 使用枚举和结构化配置,而不是“魔法数字”(整型常量),来优化启动器在窗口模式、进程优先级、渲染器选择、JVM 参数以及音乐/背景处理方面的行为。
Original summary in English

Summary by Sourcery

Replace legacy ModBase.Setup usage with strongly-typed configuration APIs across launcher UI, instance settings, and Minecraft modules, while simplifying VB compatibility helpers and aligning migration and hint logic with the new config/state layout.

Bug Fixes:

  • Prevent invalid download mirror mode configuration by falling back to a balanced strategy when the stored value is out of range.
  • Avoid crashes when handling encrypted or missing config keys in event handling and argument replacement by checking config item metadata before reading or writing.

Enhancements:

  • Use strongly-typed Config/ConfigService properties for global and per-instance settings instead of ModBase.Setup in launch flow, download logic, profiles, and Minecraft instance management.
  • Wire setup UI pages (launcher, game manage, game link, UI, launcher misc, instance setup) directly to config objects via tag-based setters, removing generic key-based get/set plumbing.
  • Simplify version and string comparison, numeric parsing, and condition checks by removing Microsoft.VisualBasic.CompilerServices operators and Conversions in favor of native C# APIs.
  • Adjust migration paths (e.g., instance isolation, mod naming, profile migration, asset-verify flags) and hint/visibility flags to rely on new config metadata and state containers.
  • Refine launcher behavior around window mode, process priority, renderer selection, JVM args, and music/background handling using enums and structured config instead of magic integers.
Original summary in English

Sourcery 总结

在启动器 UI、实例设置和 Minecraft 模块中,用强类型配置 API 替换遗留的 ModBase.Setup 用法,同时简化 VB 兼容性辅助方法,并使迁移逻辑和提示逻辑与新的配置/状态布局保持一致。

Bug 修复:

  • 当已存储的下载镜像模式配置值超出范围时,回退到“平衡”策略,防止出现无效的下载镜像模式配置。
  • 在事件处理和参数替换中处理加密或缺失的配置键时,通过在读写前检查配置项元数据,避免发生崩溃。

增强改进:

  • 在启动流程、下载逻辑、配置文件和 Minecraft 实例管理中,针对全局和每实例设置使用强类型的 Config/ConfigService 属性,而不是使用 ModBase.Setup
  • 通过基于标签的 setter 将设置 UI 页面(启动器、游戏管理、游戏关联、UI、启动器杂项、实例设置)直接连接到配置对象上,移除基于通用键的 get/set 管道。
  • 通过移除 Microsoft.VisualBasic.CompilerServices 中的运算符和 Conversions,改用原生 C# API 来简化版本和字符串比较、数值解析以及条件检查。
  • 调整迁移路径(例如实例隔离、模组命名、配置文件迁移、资源校验标志)以及提示/可见性标志,使其依赖新的配置元数据和状态容器。
  • 使用枚举和结构化配置,而不是“魔法数字”(整型常量),来优化启动器在窗口模式、进程优先级、渲染器选择、JVM 参数以及音乐/背景处理方面的行为。
Original summary in English

Summary by Sourcery

Replace legacy ModBase.Setup usage with strongly-typed configuration APIs across launcher UI, instance settings, and Minecraft modules, while simplifying VB compatibility helpers and aligning migration and hint logic with the new config/state layout.

Bug Fixes:

  • Prevent invalid download mirror mode configuration by falling back to a balanced strategy when the stored value is out of range.
  • Avoid crashes when handling encrypted or missing config keys in event handling and argument replacement by checking config item metadata before reading or writing.

Enhancements:

  • Use strongly-typed Config/ConfigService properties for global and per-instance settings instead of ModBase.Setup in launch flow, download logic, profiles, and Minecraft instance management.
  • Wire setup UI pages (launcher, game manage, game link, UI, launcher misc, instance setup) directly to config objects via tag-based setters, removing generic key-based get/set plumbing.
  • Simplify version and string comparison, numeric parsing, and condition checks by removing Microsoft.VisualBasic.CompilerServices operators and Conversions in favor of native C# APIs.
  • Adjust migration paths (e.g., instance isolation, mod naming, profile migration, asset-verify flags) and hint/visibility flags to rely on new config metadata and state containers.
  • Refine launcher behavior around window mode, process priority, renderer selection, JVM args, and music/background handling using enums and structured config instead of magic integers.

@pcl-ce-automation pcl-ce-automation Bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 size: L PR 大小评估:大型 labels May 20, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 20, 2026

审阅者指南

将启动器、Minecraft 和 UI 代码重构为使用新的强类型 Config/ConfigService 和 States 结构,替代 ModBase.Setup 和 VB.CompilerServices;为从 UI 控件保存全局和按实例设置引入基于 Tag 的映射辅助方法;并在更新配置模型的同时,对遗留迁移、校验、下载和事件逻辑进行对齐以及现代化各种字符串/数字处理路径。

基于 Tag 的 UI 设置更新时序图

sequenceDiagram
    actor User
    participant PageSetupUI
    participant SetByTag
    participant Config

    User->>PageSetupUI: Drag SliderLauncherOpacity
    PageSetupUI->>PageSetupUI: SliderChange(sender, user)
    PageSetupUI->>SetByTag: SetByTag(sender.Tag, sender.Value)
    SetByTag->>Config: Preference.Theme.WindowOpacity = value

    User->>PageSetupUI: Toggle CheckMusicStop
    PageSetupUI->>PageSetupUI: CheckBoxChange(sender, user)
    PageSetupUI->>SetByTag: SetByTag(sender.Tag, sender.Checked)
    SetByTag->>Config: Preference.Music.StopInGame = value
Loading

文件级改动

Change Details Files
将基于 ModBase.Setup 和 VB.CompilerServices 的访问替换为在启动、实例、配置文件和下载流程中使用强类型的 Config/ConfigService 和 States。
  • 在 ModLaunch、ModMinecraft、ModDownload、ModProfile、ModJava、ModEvent、ModMain、Application 及其他模块中,使用强类型的 Config.Debug、Config.Launch、Config.Preference、Config.Download、Config.Link 和 States.,替代 ModBase.Setup.Get/Set/Reset 和 Conversions/Operators。
  • 将基于 Operators.ConditionalCompareObject、Conversions.* 的比较与转换,切换为原生 C# API,如 string.CompareOrdinal、int.Parse、double.Parse、long.Parse,以及直接的枚举/整型比较。
  • 重做遗留迁移逻辑(例如配置文件、版本隔离、Mod 命名、资源校验、Java 选择),通过新的配置元数据(IsDefault/Reset/DefaultValue)和专门的状态字段进行读写,而不是使用通用的 setup 键。
Modules/Minecraft/ModLaunch.cs
Modules/Minecraft/ModMinecraft.cs
Modules/Minecraft/ModDownload.cs
Modules/Minecraft/ModProfile.cs
Modules/Minecraft/ModJava.cs
Modules/Base/ModBase.cs
Modules/Base/ModSetup.cs
Modules/ModEvent.cs
Modules/ModMain.cs
Application.xaml.cs
引入基于 Tag 的辅助方法,将 UI 控件映射到强类型配置字段,用于全局启动器设置和按实例设置。
  • 在设置页面(UI、Launch、GameManage、GameLink、LauncherMisc)中,用页面专属的 SetByTag 辅助方法替换通用的 ModBase.Setup.Set/Load 调用,这些辅助方法根据控件的 Tag 值进行分发,并写入 Config. 属性。
  • 在实例设置页面中,新增 SetInstanceByTag 和直接使用 ArgConfig,使实例级选项(内存、认证、资源校验、Java 启动参数)通过 Config.Instance/Config.InstanceAuth 而不是 ModBase.Setup 进行写入。
  • 更新单选框/复选框/滑块/文本框事件处理程序,使其依赖这些 Tag 辅助方法,并使用具体的枚举类型(例如 GameWindowSizeMode、LauncherVisibility、GameProcessPriority、LinkRelayBehavior)而非魔法整数。
Pages/PageSetup/PageSetupUI.xaml.cs
Pages/PageSetup/PageSetupLaunch.xaml.cs
Pages/PageSetup/PageSetupGameManage.xaml.cs
Pages/PageSetup/PageSetupGameLink.xaml.cs
Pages/PageSetup/PageSetupLauncherMisc.xaml.cs
Pages/PageInstance/PageInstanceSetup.xaml.cs
使启动器启动流程、UI 初始化、提示以及自定义命令/事件处理与新的配置和状态结构保持一致。
  • 移除已过时的通用 ModBase.Setup 方法(Set/Get/Load/Reset/IsUnset/GetDefault/GetSafe/SetSafe),并修改 ModSetup.Ui* 方法,使其基于 Config.Preference 和静态辅助方法工作,而不是基于 Setup 键。
  • 更新应用程序与主窗口启动逻辑,主动访问强类型配置属性(如主题、HTTP 代理、下载限制、提示),并使用 ModSetup 辅助方法应用标题/Logo 等 UI 状态。
  • 重构 MyHint 和事件处理,使用带 ConfigSource 检查的 ConfigService.TryGetConfigItemNoType 以及 States.Hint 字段来实现一次性提示屏蔽和事件安全确认,替代临时的 Setup 标志和加密键。
  • 调整各种杂项 UI 行为(背景刷新、隐藏面板、音乐/视频行为、进程优先级、启动器可见性),直接使用新的枚举/布尔字段。
Modules/Base/ModSetup.cs
FormMain.xaml.cs
Application.xaml.cs
Controls/MyHint.xaml.cs
Modules/ModEvent.cs
Pages/PageSetup/PageSetupUI.xaml.cs
Pages/PageSetup/PageSetupGameManage.xaml.cs
Pages/PageSetup/PageSetupLauncherMisc.xaml.cs

可能关联的 Issue

  • #【占位】: Issue 预告重构 ModBase 及相关文件,本 PR 正在替换 ModBase.Setup 并重构其引用代码。

提示与命令

与 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 来触发新的审查!

自定义使用体验

访问你的 dashboard 以:

  • 启用或禁用审查特性,例如 Sourcery 自动生成的 pull request 总结、审阅者指南等。
  • 修改审查使用的语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Refactors launcher, Minecraft, and UI code to use the new strongly-typed Config/ConfigService and States structures instead of ModBase.Setup and VB.CompilerServices, introduces tag-based mapping helpers for saving global and per-instance settings from UI controls, and aligns legacy migration, validation, download, and event logic with the updated configuration model while modernizing various string/number handling paths.

Sequence diagram for tag-based UI setting updates

sequenceDiagram
    actor User
    participant PageSetupUI
    participant SetByTag
    participant Config

    User->>PageSetupUI: Drag SliderLauncherOpacity
    PageSetupUI->>PageSetupUI: SliderChange(sender, user)
    PageSetupUI->>SetByTag: SetByTag(sender.Tag, sender.Value)
    SetByTag->>Config: Preference.Theme.WindowOpacity = value

    User->>PageSetupUI: Toggle CheckMusicStop
    PageSetupUI->>PageSetupUI: CheckBoxChange(sender, user)
    PageSetupUI->>SetByTag: SetByTag(sender.Tag, sender.Checked)
    SetByTag->>Config: Preference.Music.StopInGame = value
Loading

File-Level Changes

Change Details Files
Replace ModBase.Setup and VB.CompilerServices-based access with strongly-typed Config/ConfigService and States usage across launch, instance, profile, and download flows.
  • Use strongly-typed Config.Debug, Config.Launch, Config.Preference, Config.Download, Config.Link, and States.* instead of ModBase.Setup.Get/Set/Reset and Conversions/Operators in ModLaunch, ModMinecraft, ModDownload, ModProfile, ModJava, ModEvent, ModMain, Application, and other modules.
  • Switch comparisons and conversions from Operators.ConditionalCompareObject*, Conversions.* to native C# APIs like string.CompareOrdinal, int.Parse, double.Parse, long.Parse, and direct enum/int comparisons.
  • Rework legacy migration logic (e.g., profiles, version isolation, Mod naming, asset verification, Java selection) to read/write via new config metadata (IsDefault/Reset/DefaultValue) and dedicated state fields instead of generic setup keys.
Modules/Minecraft/ModLaunch.cs
Modules/Minecraft/ModMinecraft.cs
Modules/Minecraft/ModDownload.cs
Modules/Minecraft/ModProfile.cs
Modules/Minecraft/ModJava.cs
Modules/Base/ModBase.cs
Modules/Base/ModSetup.cs
Modules/ModEvent.cs
Modules/ModMain.cs
Application.xaml.cs
Introduce tag-based helpers to map UI controls to strongly-typed config fields for global launcher settings and per-instance settings.
  • On settings pages (UI, Launch, GameManage, GameLink, LauncherMisc) replace generic ModBase.Setup.Set/Load calls with page-specific SetByTag helpers that switch on control Tag values and assign into Config. properties.
  • On the instance setup page, add SetInstanceByTag and direct ArgConfig usage so that instance-level options (memory, auth, asset verification, Java flags) write through Config.Instance/Config.InstanceAuth rather than ModBase.Setup.
  • Update radio/checkbox/slider/textbox handlers to rely on these tag helpers and to use concrete enum types (e.g., GameWindowSizeMode, LauncherVisibility, GameProcessPriority, LinkRelayBehavior) instead of magic integers.
Pages/PageSetup/PageSetupUI.xaml.cs
Pages/PageSetup/PageSetupLaunch.xaml.cs
Pages/PageSetup/PageSetupGameManage.xaml.cs
Pages/PageSetup/PageSetupGameLink.xaml.cs
Pages/PageSetup/PageSetupLauncherMisc.xaml.cs
Pages/PageInstance/PageInstanceSetup.xaml.cs
Align launcher startup, UI initialization, hints, and custom command/event handling with the new configuration and state structures.
  • Remove now-obsolete generic ModBase.Setup methods (Set/Get/Load/Reset/IsUnset/GetDefault/GetSafe/SetSafe) and change ModSetup.Ui* methods to operate on Config.Preference and static helpers instead of Setup keys.
  • Update application and main window startup to eagerly touch strongly-typed config properties (e.g., theme, HTTP proxy, download limits, hints) and use ModSetup helpers to apply title/logo UI state.
  • Refactor MyHint and Event handling to use ConfigService.TryGetConfigItemNoType with ConfigSource checks and States.Hint fields for one-time hint suppression and event safety confirmation, instead of ad-hoc Setup flags and encrypted keys.
  • Adjust various misc UI behaviors (background refresh, hidden panels, music/video behavior, process priority, launcher visibility) to use the new enums/booleans directly.
Modules/Base/ModSetup.cs
FormMain.xaml.cs
Application.xaml.cs
Controls/MyHint.xaml.cs
Modules/ModEvent.cs
Pages/PageSetup/PageSetupUI.xaml.cs
Pages/PageSetup/PageSetupGameManage.xaml.cs
Pages/PageSetup/PageSetupLauncherMisc.xaml.cs

Possibly linked issues

  • #【占位】: Issue 预告重构 ModBase 及相关文件,本 PR 正在替换 ModBase.Setup 并重构其引用代码。

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

@LuLu-ling LuLu-ling added the ⚠️ 破坏性 涉及对启动器核心功能有潜在破坏风险的更改,需特别谨慎评估和测试 label May 20, 2026
@LuLu-ling LuLu-ling force-pushed the refactor/ModBase-Setup branch from 8b9c4d3 to 8af4c2a Compare May 21, 2026 09:54
@pcl-ce-automation pcl-ce-automation Bot added size: XL PR 大小评估:超大型 and removed ⚠️ 破坏性 涉及对启动器核心功能有潜在破坏风险的更改,需特别谨慎评估和测试 size: L PR 大小评估:大型 labels May 21, 2026
@LuLu-ling LuLu-ling changed the title refactor: 使用配置系统全面取代 ModBase.Setup refactor: 使用配置系统全面取代 ModBase.Setup 并移除部分 VB.CompilerServices May 21, 2026
@LuLu-ling LuLu-ling marked this pull request as ready for review May 21, 2026 11:25
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 labels May 21, 2026
@LuLu-ling LuLu-ling requested a review from a team May 21, 2026 11:25
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,我在这里给出了一些整体性的反馈:

  • 在各个 Set*ByTag 辅助方法中(例如 SetByTagSetLaunchByTagSetGameManageByTagSetInstanceByTag),很多分支会把 object value 直接强制转换为 int / double / bool,但调用方(滑块等)往往会传入 double 或可空类型,这可能会抛出 InvalidCastException。建议使用 Convert.ToInt32 / Convert.ToDouble 并结合空值安全处理,而不是直接强转。
  • 新的直接配置 setter 绕过了旧的 ModBase.Setup 事件/副作用机制;对于之前依赖变更回调的选项(例如 logo 类型/标题的更新、一些 UI 刷新操作),请仔细检查:确保在用户修改设置时仍然会调用等价的方法(如 ModSetup.UiLogoType/UiLogoText/UiLogoLeft),而不是只在启动时调用一次。
  • MyHint 中,加载/关闭逻辑现在使用 ConfigService.TryGetConfigItemNoType(...).GetValueNoType() 来决定可见性并持久化关闭状态;请确认对应的配置项在未设置时的状态是 null(或使用 IsDefault),以避免因为非空默认值导致提示在一开始就被隐藏。
给 AI 智能体的提示
Please address the comments from this code review:

## Overall Comments
- In the various `Set*ByTag` helpers (e.g. `SetByTag`, `SetLaunchByTag`, `SetGameManageByTag`, `SetInstanceByTag`), many cases cast `object value` directly to `int`/`double`/`bool`, but the callers (sliders, etc.) often pass a `double` or nullable type, which can throw `InvalidCastException`; consider using `Convert.ToInt32`/`Convert.ToDouble` and null-safe handling instead of direct casts.
- The new direct-config setters bypass the old `ModBase.Setup` event/side-effect mechanism; for options that previously relied on change callbacks (e.g. logo type/title updates, some UI refresh actions), double-check that equivalent calls (like `ModSetup.UiLogoType/UiLogoText/UiLogoLeft`) are still invoked on user changes rather than only at startup.
- In `MyHint`, the loaded/close logic now uses `ConfigService.TryGetConfigItemNoType(...).GetValueNoType()` to decide visibility and persist dismissal; verify that the corresponding config items have `null` as their unset state (or use `IsDefault`) so that hints are not hidden immediately due to a non-null default value.

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

Hey - I've left some high level feedback:

  • In the various Set*ByTag helpers (e.g. SetByTag, SetLaunchByTag, SetGameManageByTag, SetInstanceByTag), many cases cast object value directly to int/double/bool, but the callers (sliders, etc.) often pass a double or nullable type, which can throw InvalidCastException; consider using Convert.ToInt32/Convert.ToDouble and null-safe handling instead of direct casts.
  • The new direct-config setters bypass the old ModBase.Setup event/side-effect mechanism; for options that previously relied on change callbacks (e.g. logo type/title updates, some UI refresh actions), double-check that equivalent calls (like ModSetup.UiLogoType/UiLogoText/UiLogoLeft) are still invoked on user changes rather than only at startup.
  • In MyHint, the loaded/close logic now uses ConfigService.TryGetConfigItemNoType(...).GetValueNoType() to decide visibility and persist dismissal; verify that the corresponding config items have null as their unset state (or use IsDefault) so that hints are not hidden immediately due to a non-null default value.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the various `Set*ByTag` helpers (e.g. `SetByTag`, `SetLaunchByTag`, `SetGameManageByTag`, `SetInstanceByTag`), many cases cast `object value` directly to `int`/`double`/`bool`, but the callers (sliders, etc.) often pass a `double` or nullable type, which can throw `InvalidCastException`; consider using `Convert.ToInt32`/`Convert.ToDouble` and null-safe handling instead of direct casts.
- The new direct-config setters bypass the old `ModBase.Setup` event/side-effect mechanism; for options that previously relied on change callbacks (e.g. logo type/title updates, some UI refresh actions), double-check that equivalent calls (like `ModSetup.UiLogoType/UiLogoText/UiLogoLeft`) are still invoked on user changes rather than only at startup.
- In `MyHint`, the loaded/close logic now uses `ConfigService.TryGetConfigItemNoType(...).GetValueNoType()` to decide visibility and persist dismissal; verify that the corresponding config items have `null` as their unset state (or use `IsDefault`) so that hints are not hidden immediately due to a non-null default value.

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.

Copy link
Copy Markdown
Member

@whitecat346 whitecat346 left a comment

Choose a reason for hiding this comment

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

i think this pr is not have problem. but you can try to improve the quality as the AI said

@whitecat346
Copy link
Copy Markdown
Member

@sourcery-ai review

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 - 我在这里给出了一些整体性的反馈:

  • 新增的基于 tag 的 setter(例如 SetByTag/SetLaunchByTag/SetGameManageByTag/SetInstanceByTag)直接进行了类型转换,如 (int)value 和 (bool)value,但调用方经常传入的是 Slider.Value(double)和 CheckBox.Checked(bool?),这样在运行时会抛出 InvalidCastException。建议改为使用 Convert.ToInt32 / Convert.ToBoolean,或者根据运行时类型做模式匹配。
  • 这些基于 tag 的 switch 帮助方法现在把配置写入逻辑集中到了一个地方,但它们依赖字符串 tag 的取值与 XAML 保持完全一致;为了在后续重构时更容易发现不匹配问题,可能更安全的做法是在 default 分支中对未知/空的 tag 做防护,并记录日志或抛出异常。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- The new tag-based setters (e.g. SetByTag/SetLaunchByTag/SetGameManageByTag/SetInstanceByTag) are performing direct casts like (int)value and (bool)value, but the callers often pass Slider.Value (double) and CheckBox.Checked (bool?) so this will throw InvalidCastException at runtime; consider using Convert.ToInt32 / Convert.ToBoolean or pattern matching on the runtime type instead.
- The tag-switch helper methods now centralize config writes, but they depend on string tag values staying perfectly in sync with XAML; it may be safer to guard unknown/empty tags with a default case that logs or throws, to make mismatches easier to detect during future refactors.

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

Hey - I've left some high level feedback:

  • The new tag-based setters (e.g. SetByTag/SetLaunchByTag/SetGameManageByTag/SetInstanceByTag) are performing direct casts like (int)value and (bool)value, but the callers often pass Slider.Value (double) and CheckBox.Checked (bool?) so this will throw InvalidCastException at runtime; consider using Convert.ToInt32 / Convert.ToBoolean or pattern matching on the runtime type instead.
  • The tag-switch helper methods now centralize config writes, but they depend on string tag values staying perfectly in sync with XAML; it may be safer to guard unknown/empty tags with a default case that logs or throws, to make mismatches easier to detect during future refactors.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new tag-based setters (e.g. SetByTag/SetLaunchByTag/SetGameManageByTag/SetInstanceByTag) are performing direct casts like (int)value and (bool)value, but the callers often pass Slider.Value (double) and CheckBox.Checked (bool?) so this will throw InvalidCastException at runtime; consider using Convert.ToInt32 / Convert.ToBoolean or pattern matching on the runtime type instead.
- The tag-switch helper methods now centralize config writes, but they depend on string tag values staying perfectly in sync with XAML; it may be safer to guard unknown/empty tags with a default case that logs or throws, to make mismatches easier to detect during future refactors.

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.

Copy link
Copy Markdown
Contributor

@Pigeon0v0 Pigeon0v0 left a comment

Choose a reason for hiding this comment

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

Sourcery 说得对,我没意见

@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels May 22, 2026
@LuLu-ling LuLu-ling merged commit 9cf8e6c into dev May 22, 2026
3 checks passed
@pcl-ce-automation pcl-ce-automation Bot added 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels May 22, 2026
@LuLu-ling LuLu-ling deleted the refactor/ModBase-Setup branch May 22, 2026 15:29
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.

3 participants