Skip to content

refactor: 移除 VisualBasic.CompilerServices 调用#2876

Open
LuLu-ling wants to merge 6 commits into
devfrom
refactor/VisualBasic-CompilerServices
Open

refactor: 移除 VisualBasic.CompilerServices 调用#2876
LuLu-ling wants to merge 6 commits into
devfrom
refactor/VisualBasic-CompilerServices

Conversation

@LuLu-ling
Copy link
Copy Markdown
Member

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

ModLoader.cs 除外

Partly Generated with DeepSeek-V4-Pro

由 Sourcery 生成的摘要

重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。

增强点:

  • 在下载和安装流程中,用标准的 C# 类型转换、相等性检查和 Convert 调用,替换 VisualBasic.CompilerServices 的转换以及 Operators 比较。
  • 通过将动态 loader 对象强制转换为具体的 loader 类型,并使用简单直接的字符串插值来生成消息,从而简化 loader 状态处理和实例清理逻辑。
  • 对导出规则采用基于 glob 的 LikeString 实现,使用 DotNet.Globbing 替代 VisualBasic 的 LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。
  • 规范 INI、布尔和数值解析,统一使用标准 .NET 转换方法以及直接的字符串/字符 API。
  • 收紧 ModBase 中的工具实现(颜色相等性判断、进制转换、哈希/MD5 辅助方法、XML/类型检查),避免使用 VisualBasic 的转换,改为依赖强类型操作。
Original summary in English

Summary by Sourcery

Refactor launcher download, install, export, and utility code to remove dependencies on VisualBasic helper APIs and use idiomatic C# types, comparisons, and conversions instead.

Enhancements:

  • Replace VisualBasic.CompilerServices conversions and Operators comparisons with standard C# casts, equality checks, and Convert calls across download and install flows.
  • Simplify loader state handling and instance cleanup logic by casting dynamic loader objects to concrete loader types and using straightforward string interpolation for messages.
  • Adopt a glob-based LikeString implementation for export rules using DotNet.Globbing in place of VisualBasic's LikeString, preserving wildcard semantics while removing the VisualBasic dependency.
  • Normalize INI, boolean, and numeric parsing to use standard .NET conversion methods and direct string/char APIs.
  • Tighten utility implementations in ModBase (color equality, radix conversion, hash/MD5 helpers, XML/type checks) to avoid VisualBasic conversions and rely on strongly-typed operations.
Original summary in English

由 Sourcery 生成的摘要

重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。

增强点:

  • 在下载和安装流程中,用标准的 C# 类型转换、相等性检查和 Convert 调用,替换 VisualBasic.CompilerServices 的转换以及 Operators 比较。
  • 通过将动态 loader 对象强制转换为具体的 loader 类型,并使用简单直接的字符串插值来生成消息,从而简化 loader 状态处理和实例清理逻辑。
  • 对导出规则采用基于 glob 的 LikeString 实现,使用 DotNet.Globbing 替代 VisualBasic 的 LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。
  • 规范 INI、布尔和数值解析,统一使用标准 .NET 转换方法以及直接的字符串/字符 API。
  • 收紧 ModBase 中的工具实现(颜色相等性判断、进制转换、哈希/MD5 辅助方法、XML/类型检查),避免使用 VisualBasic 的转换,改为依赖强类型操作。
Original summary in English

Summary by Sourcery

Refactor launcher download, install, export, and utility code to remove dependencies on VisualBasic helper APIs and use idiomatic C# types, comparisons, and conversions instead.

Enhancements:

  • Replace VisualBasic.CompilerServices conversions and Operators comparisons with standard C# casts, equality checks, and Convert calls across download and install flows.
  • Simplify loader state handling and instance cleanup logic by casting dynamic loader objects to concrete loader types and using straightforward string interpolation for messages.
  • Adopt a glob-based LikeString implementation for export rules using DotNet.Globbing in place of VisualBasic's LikeString, preserving wildcard semantics while removing the VisualBasic dependency.
  • Normalize INI, boolean, and numeric parsing to use standard .NET conversion methods and direct string/char APIs.
  • Tighten utility implementations in ModBase (color equality, radix conversion, hash/MD5 helpers, XML/type checks) to avoid VisualBasic conversions and rely on strongly-typed operations.

增强内容:

  • 将基于 VB 风格 Conversions/Operators 的条件检查、类型转换和比较重构为原生 C# 运算符以及 Convert/Equals 的用法,以简化并明确逻辑。
  • 用内部基于正则表达式的通配符匹配器替换 VisualBasic 的 LikeString 用法,用于导出规则,同时保留原有的模式语义。
  • 通过使用字符串插值和直接拼接来清理字符串处理逻辑,替代 VB 辅助方法,并调整 INI/布尔值解析逻辑以使用标准的 .NET 转换方式。
  • 更新哈希和颜色相关的工具代码,改用直接强制转换和类型化相等比较,移除对 VisualBasic 转换的依赖。
Original summary in English

由 Sourcery 生成的摘要

重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。

增强点:

  • 在下载和安装流程中,用标准的 C# 类型转换、相等性检查和 Convert 调用,替换 VisualBasic.CompilerServices 的转换以及 Operators 比较。
  • 通过将动态 loader 对象强制转换为具体的 loader 类型,并使用简单直接的字符串插值来生成消息,从而简化 loader 状态处理和实例清理逻辑。
  • 对导出规则采用基于 glob 的 LikeString 实现,使用 DotNet.Globbing 替代 VisualBasic 的 LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。
  • 规范 INI、布尔和数值解析,统一使用标准 .NET 转换方法以及直接的字符串/字符 API。
  • 收紧 ModBase 中的工具实现(颜色相等性判断、进制转换、哈希/MD5 辅助方法、XML/类型检查),避免使用 VisualBasic 的转换,改为依赖强类型操作。
Original summary in English

Summary by Sourcery

Refactor launcher download, install, export, and utility code to remove dependencies on VisualBasic helper APIs and use idiomatic C# types, comparisons, and conversions instead.

Enhancements:

  • Replace VisualBasic.CompilerServices conversions and Operators comparisons with standard C# casts, equality checks, and Convert calls across download and install flows.
  • Simplify loader state handling and instance cleanup logic by casting dynamic loader objects to concrete loader types and using straightforward string interpolation for messages.
  • Adopt a glob-based LikeString implementation for export rules using DotNet.Globbing in place of VisualBasic's LikeString, preserving wildcard semantics while removing the VisualBasic dependency.
  • Normalize INI, boolean, and numeric parsing to use standard .NET conversion methods and direct string/char APIs.
  • Tighten utility implementations in ModBase (color equality, radix conversion, hash/MD5 helpers, XML/type checks) to avoid VisualBasic conversions and rely on strongly-typed operations.
Original summary in English

由 Sourcery 生成的摘要

重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。

增强点:

  • 在下载和安装流程中,用标准的 C# 类型转换、相等性检查和 Convert 调用,替换 VisualBasic.CompilerServices 的转换以及 Operators 比较。
  • 通过将动态 loader 对象强制转换为具体的 loader 类型,并使用简单直接的字符串插值来生成消息,从而简化 loader 状态处理和实例清理逻辑。
  • 对导出规则采用基于 glob 的 LikeString 实现,使用 DotNet.Globbing 替代 VisualBasic 的 LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。
  • 规范 INI、布尔和数值解析,统一使用标准 .NET 转换方法以及直接的字符串/字符 API。
  • 收紧 ModBase 中的工具实现(颜色相等性判断、进制转换、哈希/MD5 辅助方法、XML/类型检查),避免使用 VisualBasic 的转换,改为依赖强类型操作。
Original summary in English

Summary by Sourcery

Refactor launcher download, install, export, and utility code to remove dependencies on VisualBasic helper APIs and use idiomatic C# types, comparisons, and conversions instead.

Enhancements:

  • Replace VisualBasic.CompilerServices conversions and Operators comparisons with standard C# casts, equality checks, and Convert calls across download and install flows.
  • Simplify loader state handling and instance cleanup logic by casting dynamic loader objects to concrete loader types and using straightforward string interpolation for messages.
  • Adopt a glob-based LikeString implementation for export rules using DotNet.Globbing in place of VisualBasic's LikeString, preserving wildcard semantics while removing the VisualBasic dependency.
  • Normalize INI, boolean, and numeric parsing to use standard .NET conversion methods and direct string/char APIs.
  • Tighten utility implementations in ModBase (color equality, radix conversion, hash/MD5 helpers, XML/type checks) to avoid VisualBasic conversions and rely on strongly-typed operations.

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

sourcery-ai Bot commented May 22, 2026

审阅者指南

通过重构多个下载 / 安装 / 导出模块以及工具模块,移除 Microsoft.VisualBasic.CompilerServices 的使用,用原生 C# 类型转换 / Convert / Equals / 字符串插值、显式的 LoaderBase/LoaderCombo 类型以及自定义的基于 glob 的 LikeString 帮助函数来替代 VB 风格的 Conversions/Operators/LikeString;同时统一 INI/配置中的布尔解析方式,并收紧相等 / 比较逻辑。

导出中 LikeString 替换的时序图

sequenceDiagram
    participant PageInstanceExport
    participant LikeString
    participant DotNet_Globbing_Glob as Glob

    PageInstanceExport->>PageInstanceExport: StartExport(sender, e)
    PageInstanceExport->>LikeString: LikeString(RelativePath, RuleTrimmed)
    LikeString->>Glob: Parse(pattern, options)
    Glob-->>LikeString: glob
    LikeString->>Glob: IsMatch(input)
    Glob-->>LikeString: bool
    LikeString-->>PageInstanceExport: bool
    PageInstanceExport->>PageInstanceExport: update ShouldKeep based on result
Loading

文件级变更

变更 详情 文件
在下载和安装流程中,用原生 C# 运算符、强类型转换以及 Convert 调用替换 VisualBasic.CompilerServices 中的 Conversions/Operators 使用,并使用强类型的 loader 对象代替动态比较。
  • 从 ModDownloadLib 和 PageDownload/PageInstance 安装页面中移除 Microsoft.VisualBasic.CompilerServices 引用。
  • 用直接的 C# 运算符、Convert.ToXEquals 以及针对 ID、版本和标志位的枚举比较来替代 Conversions.ToString/ToBoolean/ToDoubleOperators.ConditionalCompareObjectEqual/NotEqual
  • 将 Loader 参数显式转换为 ModLoader.LoaderBase/LoaderCombo,直接访问 Name/Error/Input/State,并重写状态处理分支,改为对 LoadState 枚举使用 switch,以及使用字符串插值生成提示信息。
  • 将动态标签(例如 sender.Tag.IsLegacy)调整为显式的 bool 强制转换,并用 Equals 和直接的 Visibility 比较来简化面板可见性检查。
Pages/PageDownload/ModDownloadLib.cs
Pages/PageInstance/PageInstanceInstall.xaml.cs
Pages/PageDownload/PageDownloadInstall.xaml.cs
通过移除 VB 的转换和运算符辅助函数,改用 .NET API 和显式、类型安全的逻辑,对 ModBase 中的工具辅助函数进行现代化改造。
  • 更新 MyColor 构造函数,对 ARGB 分量使用 Convert.ToDouble,并用显式的按字段比较实现 Equals,替代 ConditionalCompareObjectEqual
  • RadixConvert 的数字查找改为使用 char.ToStringDigits.IndexOfF,消除对 Conversions.ToString 的依赖。
  • 让哈希函数(GetFileMD5/SHA1/SHA256/SHA512/GetAuthSHA1/GetStringMD5)通过从 GetHexString 的结果直接转换为字符串返回,而不再使用 VB Conversions。
  • 在路径拼接时使用 Path.DirectorySeparatorChar.ToStringStrFill/StrTrim 中使用字符字面量代替 Conversions.ToChar,在 GetFullList 中用泛型强制转换 (T)data[i] 替代 Conversions.ToGenericParameter
  • 在 XML 反序列化黑名单检查和 Visibility 转换器中,用 Equals 和直接的枚举比较替换 Operators 的条件比较。
Modules/Base/ModBase.cs
用自定义的基于 glob 的匹配器替换导出逻辑中的 VB LikeString 过滤,同时清理导出页面中的可见性检查以及 INI 布尔解析。
  • 从导出页面移除 Microsoft.VisualBasicCompilerServices,并添加 DotNet.Globbing;引入私有的 LikeString 帮助函数,用于解析 glob 模式(不区分大小写)并通过 Glob.IsMatch 进行匹配测试。
  • 在可见性检查和文件保留规则中使用新的 LikeString 帮助函数来执行导出规则匹配,而不是 LikeOperator.LikeString
  • GetAllOptions 中,将 UIElement 的可见性过滤简化为直接的 Visibility 比较。
  • ReadConfigFile 中统一基于 INI 的布尔解析方式,使用 Convert.ToBoolean,并用 true/false.ToString 表达默认值;同时调整 EndsWithF 调用,改为使用 bool ignoreCase 参数,而非 Conversions.ToBoolean
Pages/PageInstance/PageInstanceExport.xaml.cs
通过用标准 .NET 的类型转换和拼接模式替换 VB 转换,规范化整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合整合模组包与启动配置的处理。
  • ModModpack 中,写入 INI 中的布尔标志时使用 true.ToString,解析 MultiMC 的布尔设置(OverrideCommands/JoinServerOnLaunch/IgnoreJavaCompatibility/OverrideJavaArgs)时对 ReadIni 结果使用 Convert.ToBoolean,而不是 Conversions.ToBoolean
  • 通过使用 C# 字符串拼接代替 Operators.ConcatenateObject,简化 JVM 参数合并逻辑。
  • ModLaunch 中,对 NetGetCodeByRequestRetry 的返回结果使用直接的 .ToString() 调用和可空处理,而不再使用 Conversions.ToString
Modules/Minecraft/ModModpack.cs
Modules/Minecraft/ModLaunch.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 来触发新审查!

自定义你的体验

访问你的 dashboard 来:

  • 启用或禁用审查特性,例如 Sourcery 生成的 Pull Request 总结、审阅者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查相关设置。

获取帮助

Original review guide in English

Reviewer's Guide

Refactors multiple download/install/export and utility modules to remove Microsoft.VisualBasic.CompilerServices usage by replacing VB-style Conversions/Operators/LikeString with native C# casts/Convert/Equals/string interpolation, explicit LoaderBase/LoaderCombo types, and a custom glob-based LikeString helper, while normalizing INI/config boolean parsing and tightening equality/comparison logic.

Sequence diagram for export LikeString replacement

sequenceDiagram
    participant PageInstanceExport
    participant LikeString
    participant DotNet_Globbing_Glob as Glob

    PageInstanceExport->>PageInstanceExport: StartExport(sender, e)
    PageInstanceExport->>LikeString: LikeString(RelativePath, RuleTrimmed)
    LikeString->>Glob: Parse(pattern, options)
    Glob-->>LikeString: glob
    LikeString->>Glob: IsMatch(input)
    Glob-->>LikeString: bool
    LikeString-->>PageInstanceExport: bool
    PageInstanceExport->>PageInstanceExport: update ShouldKeep based on result
Loading

File-Level Changes

Change Details Files
Replace VisualBasic.CompilerServices Conversions/Operators usage in download and install flows with native C# operators, casts, and Convert calls, and use strongly-typed loader objects instead of dynamic comparisons.
  • Remove Microsoft.VisualBasic.CompilerServices import from ModDownloadLib and PageDownload/PageInstance install pages.
  • Replace Conversions.ToString/ToBoolean/ToDouble and Operators.ConditionalCompareObjectEqual/NotEqual with direct C# operators, Convert.ToX, Equals, and enum comparisons for IDs, versions, and flags.
  • Cast Loader parameters to ModLoader.LoaderBase/LoaderCombo, access Name/Error/Input/State directly, and rewrite state-handling branches to use switch on LoadState enums and string interpolation for hint messages.
  • Adjust dynamic tags (e.g., sender.Tag.IsLegacy) to explicit bool casts, and simplify panel visibility checks using Equals and direct Visibility comparison.
Pages/PageDownload/ModDownloadLib.cs
Pages/PageInstance/PageInstanceInstall.xaml.cs
Pages/PageDownload/PageDownloadInstall.xaml.cs
Modernize utility helpers in ModBase by removing VB conversions and operator helpers in favor of .NET APIs and explicit type-safe logic.
  • Update MyColor constructor to use Convert.ToDouble for ARGB components and implement Equals with explicit field-wise comparisons instead of ConditionalCompareObjectEqual.
  • Change RadixConvert digit lookup to use char.ToString and Digits.IndexOfF, eliminating Conversions.ToString.
  • Return hashing helpers (GetFileMD5/SHA1/SHA256/SHA512/GetAuthSHA1/GetStringMD5) as strings via direct casting from GetHexString without VB Conversions.
  • Use Path.DirectorySeparatorChar.ToString for path concatenation, char literals for StrFill/StrTrim instead of Conversions.ToChar, and generic casts (T)data[i] in GetFullList instead of Conversions.ToGenericParameter.
  • In XML deserialization blacklist checks and Visibility converter, replace Operators conditional compares with Equals and direct enum comparisons.
Modules/Base/ModBase.cs
Replace VB LikeString-based export filtering with a custom glob-based matcher and clean up visibility checks and INI bool parsing in the export page.
  • Remove Microsoft.VisualBasic and CompilerServices from export page and add DotNet.Globbing; introduce a private LikeString helper that parses glob patterns (case-insensitive) and tests matches via Glob.IsMatch.
  • Use the new LikeString helper for export rule matching in visibility checks and file-keep rules instead of LikeOperator.LikeString.
  • Simplify UIElement visibility filters in GetAllOptions to direct Visibility comparisons.
  • Normalize INI-based boolean parsing in ReadConfigFile to use Convert.ToBoolean with default values expressed via true/false.ToString, and adjust EndsWithF calls to use bool ignoreCase instead of Conversions.ToBoolean.
Pages/PageInstance/PageInstanceExport.xaml.cs
Normalize modpack and launch configuration handling by replacing VB conversions with standard .NET conversion and concatenation patterns.
  • In ModModpack, write boolean INI flags using true.ToString and parse MultiMC boolean settings (OverrideCommands/JoinServerOnLaunch/IgnoreJavaCompatibility/OverrideJavaArgs) via Convert.ToBoolean on ReadIni results, instead of Conversions.ToBoolean.
  • Simplify JVM args merging by using C# string concatenation instead of Operators.ConcatenateObject.
  • In ModLaunch, replace Conversions.ToString on NetGetCodeByRequestRetry result with a direct ToString() call and nullable handling.
Modules/Minecraft/ModModpack.cs
Modules/Minecraft/ModLaunch.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

@LuLu-ling LuLu-ling marked this pull request as ready for review May 22, 2026 17:38
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 labels May 22, 2026
@LuLu-ling LuLu-ling requested a review from a team May 22, 2026 17:38
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 - 我在这里给出了一些高层次的反馈:

  • OptiFine_Loaded 中,Versions.Sort 的比较委托现在返回的是 ModMinecraft.CompareVersion(...) != 0,这会产生一个 bool,而不是 Comparison<T> 所期望的 int;这要么无法通过编译,要么会导致排序错误,应该改为返回原本的比较结果值。
  • PageInstanceExport 中新的 LikeString 实现通过正则表达式重新实现了 VB 的 Like 语义;考虑到其中细微的模式规则(例如字符类、区间和取反),更安全的做法是将其行为与 VB 的 Like 针对典型导出规则进行仔细对比,以确保没有回归。
面向 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- In `OptiFine_Loaded` the `Versions.Sort` comparison delegate now returns `ModMinecraft.CompareVersion(...) != 0`, which produces a `bool` rather than the expected `int` for a `Comparison<T>`; this will either not compile or sort incorrectly and should return the original comparison value.
- The new `LikeString` implementation in `PageInstanceExport` reimplements VB's `Like` semantics via regex; given the subtle pattern rules (e.g., character classes, ranges, and negation), it would be safer to carefully cross-check its behavior against VB `Like` for typical export rules to ensure no regressions.

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

Hey - I've left some high level feedback:

  • In OptiFine_Loaded the Versions.Sort comparison delegate now returns ModMinecraft.CompareVersion(...) != 0, which produces a bool rather than the expected int for a Comparison<T>; this will either not compile or sort incorrectly and should return the original comparison value.
  • The new LikeString implementation in PageInstanceExport reimplements VB's Like semantics via regex; given the subtle pattern rules (e.g., character classes, ranges, and negation), it would be safer to carefully cross-check its behavior against VB Like for typical export rules to ensure no regressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `OptiFine_Loaded` the `Versions.Sort` comparison delegate now returns `ModMinecraft.CompareVersion(...) != 0`, which produces a `bool` rather than the expected `int` for a `Comparison<T>`; this will either not compile or sort incorrectly and should return the original comparison value.
- The new `LikeString` implementation in `PageInstanceExport` reimplements VB's `Like` semantics via regex; given the subtle pattern rules (e.g., character classes, ranges, and negation), it would be safer to carefully cross-check its behavior against VB `Like` for typical export rules to ensure no regressions.

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.

@LuLu-ling
Copy link
Copy Markdown
Member Author

@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 - 我在这里给出了一些高层次的反馈:

  • Conversions.ToDouble 替换为 Convert.ToDouble 的几个改动(例如在 LoaderVersion.BeforeFirst(".")OptiFine.RequiredForgeVersion 上)现在会依赖当前区域设置的小数点分隔符;如果这些字符串始终使用 . 作为小数点,你可能需要改用 double.Parse(..., CultureInfo.InvariantCulture),以避免因区域设置不同而产生的行为差异。
  • 使用 DotNet.Globbing 的新 LikeString 实现,相比 VB 的 Like 更改了模式语法和匹配规则(例如字符类、#? 的语义);如果保持现有导出规则的行为很重要,建议在完全切换之前增加一个兼容层,或围绕典型模式补充一些测试。
  • Conversions.ToString 替换为 ?.ToString() 的地方(例如 ModDownload.DlClientListGet(id)ModNet.NetGetCodeByRequestRetry 周边),调用方现在需要处理可能出现的 null 值,而不是空字符串;请检查这些调用路径,确保下游 API 要么可以接受 null,要么在调用前有恰当的保护。
提供给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- Several replacements of `Conversions.ToDouble` with `Convert.ToDouble` (e.g. on `LoaderVersion.BeforeFirst(".")` and `OptiFine.RequiredForgeVersion`) now depend on the current culture’s decimal separator; if these strings always use `.` you may want to switch to `double.Parse(..., CultureInfo.InvariantCulture)` to avoid locale‑dependent behavior.
- The new `LikeString` implementation using DotNet.Globbing changes the pattern syntax and matching rules compared to VB’s `Like` (e.g. character classes, `#`, `?` semantics); if preserving existing export rule behavior is important, consider adding a compatibility layer or tests around typical patterns before fully switching.
- Where `Conversions.ToString` was replaced with `?.ToString()` (for example around `ModDownload.DlClientListGet(id)` and `ModNet.NetGetCodeByRequestRetry`), the call sites now have to handle possible `null` values instead of an empty string; review those paths to ensure downstream APIs either accept `null` or are guarded appropriately.

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

Hey - I've left some high level feedback:

  • Several replacements of Conversions.ToDouble with Convert.ToDouble (e.g. on LoaderVersion.BeforeFirst(".") and OptiFine.RequiredForgeVersion) now depend on the current culture’s decimal separator; if these strings always use . you may want to switch to double.Parse(..., CultureInfo.InvariantCulture) to avoid locale‑dependent behavior.
  • The new LikeString implementation using DotNet.Globbing changes the pattern syntax and matching rules compared to VB’s Like (e.g. character classes, #, ? semantics); if preserving existing export rule behavior is important, consider adding a compatibility layer or tests around typical patterns before fully switching.
  • Where Conversions.ToString was replaced with ?.ToString() (for example around ModDownload.DlClientListGet(id) and ModNet.NetGetCodeByRequestRetry), the call sites now have to handle possible null values instead of an empty string; review those paths to ensure downstream APIs either accept null or are guarded appropriately.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Several replacements of `Conversions.ToDouble` with `Convert.ToDouble` (e.g. on `LoaderVersion.BeforeFirst(".")` and `OptiFine.RequiredForgeVersion`) now depend on the current culture’s decimal separator; if these strings always use `.` you may want to switch to `double.Parse(..., CultureInfo.InvariantCulture)` to avoid locale‑dependent behavior.
- The new `LikeString` implementation using DotNet.Globbing changes the pattern syntax and matching rules compared to VB’s `Like` (e.g. character classes, `#`, `?` semantics); if preserving existing export rule behavior is important, consider adding a compatibility layer or tests around typical patterns before fully switching.
- Where `Conversions.ToString` was replaced with `?.ToString()` (for example around `ModDownload.DlClientListGet(id)` and `ModNet.NetGetCodeByRequestRetry`), the call sites now have to handle possible `null` values instead of an empty string; review those paths to ensure downstream APIs either accept `null` or are guarded appropriately.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L PR 大小评估:大型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant