fix(comp): CompFile 的集合字段初始化为空列表,避免 ToJson 空引用崩溃#3352
Open
NoClassFoundError wants to merge 1 commit into
Open
Conversation
Contributor
审查者指南(在小型 PR 上折叠)审查者指南在 CompFile 中将三个只读集合字段初始化为空列表,以防止在 JSON 序列化和列表项生成期间出现空引用崩溃。 文件级更改
与关联 Issue 的对照评估
可能关联的 Issue
提示和命令与 Sourcery 交互
自定义你的使用体验访问你的 控制面板 以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideInitializes three readonly collection fields in CompFile to empty lists to prevent null reference crashes during JSON serialization and list item generation. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
你好,我已经审查了你的修改,看起来非常棒!
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English
Hey - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
LuLu-ling
approved these changes
Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CompFile 的 ModLoaders / RawGameVersions / GameVersions 三个 readonly 集合字段声明处未初始化,而 CompFile(JsonObject) 构造函数仅在缓存 JSON 含对应键时才赋值(if ContainsKey)。
当数据缺失这些键时字段保持 null,随后 CompFile.ToJson() 对其调用 .Select() 便抛出ArgumentNullException(Parameter 'source'),表现为启用/禁用某些模组时启动器直接崩溃弹错误窗口;ToListItem 中的 GameVersions.All(...) 亦会因 null 崩溃。
为这三个字段声明补上 = new(),与 Dependencies 等其他集合字段一致,从源头保证非 null。
resolves #3058
本PR的提交信息生成由Claude Code Opus 4.8辅助完成,由Opus 4.8对代码进行了审查。
Summary by Sourcery
Bug Fixes:
CompFile中的RawGameVersions、GameVersions和ModLoaders始终初始化为空列表,以避免在 JSON 序列化和进行列表操作时触发ArgumentNullException。Original summary in English
Summary by Sourcery
Bug Fixes: