refactor: 移除 VisualBasic.CompilerServices 调用#2876
Conversation
审阅者指南通过重构多个下载 / 安装 / 导出模块以及工具模块,移除 导出中 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
文件级变更
技巧与命令与 Sourcery 交互
自定义你的体验访问你的 dashboard 来:
获取帮助Original review guide in EnglishReviewer's GuideRefactors 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 replacementsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- In
OptiFine_LoadedtheVersions.Sortcomparison delegate now returnsModMinecraft.CompareVersion(...) != 0, which produces aboolrather than the expectedintfor aComparison<T>; this will either not compile or sort incorrectly and should return the original comparison value. - The new
LikeStringimplementation inPageInstanceExportreimplements VB'sLikesemantics 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 VBLikefor 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
There was a problem hiding this comment.
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.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- Several replacements of
Conversions.ToDoublewithConvert.ToDouble(e.g. onLoaderVersion.BeforeFirst(".")andOptiFine.RequiredForgeVersion) now depend on the current culture’s decimal separator; if these strings always use.you may want to switch todouble.Parse(..., CultureInfo.InvariantCulture)to avoid locale‑dependent behavior. - The new
LikeStringimplementation using DotNet.Globbing changes the pattern syntax and matching rules compared to VB’sLike(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.ToStringwas replaced with?.ToString()(for example aroundModDownload.DlClientListGet(id)andModNet.NetGetCodeByRequestRetry), the call sites now have to handle possiblenullvalues instead of an empty string; review those paths to ensure downstream APIs either acceptnullor 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
ModLoader.cs 除外
由 Sourcery 生成的摘要
重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。
增强点:
Convert调用,替换VisualBasic.CompilerServices的转换以及Operators比较。LikeString实现,使用DotNet.Globbing替代 VisualBasic 的LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。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:
Original summary in English
由 Sourcery 生成的摘要
重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。
增强点:
Convert调用,替换VisualBasic.CompilerServices的转换以及Operators比较。LikeString实现,使用DotNet.Globbing替代 VisualBasic 的LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。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:
增强内容:
Conversions/Operators的条件检查、类型转换和比较重构为原生 C# 运算符以及Convert/Equals的用法,以简化并明确逻辑。LikeString用法,用于导出规则,同时保留原有的模式语义。Original summary in English
由 Sourcery 生成的摘要
重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。
增强点:
Convert调用,替换VisualBasic.CompilerServices的转换以及Operators比较。LikeString实现,使用DotNet.Globbing替代 VisualBasic 的LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。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:
Original summary in English
由 Sourcery 生成的摘要
重构启动器的下载、安装、导出以及工具代码,移除对 VisualBasic 辅助 API 的依赖,改用更符合 C# 习惯用法的类型、比较和转换。
增强点:
Convert调用,替换VisualBasic.CompilerServices的转换以及Operators比较。LikeString实现,使用DotNet.Globbing替代 VisualBasic 的LikeString,在移除对 VisualBasic 依赖的同时保留通配符语义。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: