Skip to content

fix(instance-export): 修复漏转换的 VB 代码#2846

Merged
Big-Cake-jpg merged 2 commits into
devfrom
fix/CopyPCL
May 17, 2026
Merged

fix(instance-export): 修复漏转换的 VB 代码#2846
Big-Cake-jpg merged 2 commits into
devfrom
fix/CopyPCL

Conversation

@LuLu-ling
Copy link
Copy Markdown
Member

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

Summary by Sourcery

Bug Fixes:

  • 修正导出逻辑,在发布构建中使用 C# 而不是遗留的 VB 代码来复制 PCL 可执行文件。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Correct the export logic to copy the PCL executable using C# instead of leftover VB code in release builds.

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

sourcery-ai Bot commented May 17, 2026

审阅者指南(在小型 PR 中折叠)

审阅者指南

重构实例导出逻辑中遗漏的 VB 风格代码片段为符合 C# 习惯用法的实现,确保在 RELEASE 构建中启用了导出选项时,PCL 可执行文件能够被正确复制。

实例导出(包含可选 PCL 可执行文件复制)的时序图

sequenceDiagram
    participant User
    participant PageInstanceExport as PageInstanceExport
    participant FileSystem

    User->>PageInstanceExport: StartExport(sender, e)
    activate PageInstanceExport
    PageInstanceExport->>FileSystem: ModBase.CopyDirectory(Path.Combine(McInstance.PathInstance, PCL), Path.Combine(OverridesFolder, PCL))
    alt [IncludePCL] and [RELEASE]
        PageInstanceExport->>FileSystem: File.Copy(ModBase.ExePathWithName, Path.Combine(CacheFolder, Plain_Craft_Launcher_exe), true)
    end
    alt [IncludePCLCustom]
        PageInstanceExport->>FileSystem: ModBase.CopyDirectory(PCL_custom_source, PCL_custom_destination)
    end
    deactivate PageInstanceExport
Loading

文件级变更

变更 详情 文件
将导出流程中剩余的 VB 风格 PCL 可执行文件条件复制逻辑,改为正确的 C# File.Copy 用法。
  • 用 C# 单行 if 语句替换已注释掉的 VB 风格条件复制代码块
  • 使用 System.IO.File.Copy,并通过 ModBase.ExePathWithName 和 Path.Combine 构建目标路径
  • 通过向 File.Copy 传入 overwrite=true 确保目标文件存在时会被覆盖
  • 保留原有的 RELEASE 条件编译指令下的行为
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceExport.xaml.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

Refactors a missed VB-style code fragment in the instance export logic to idiomatic C#, ensuring the PCL executable is copied correctly during export when enabled in RELEASE builds.

Sequence diagram for instance export including optional PCL executable copy

sequenceDiagram
    participant User
    participant PageInstanceExport as PageInstanceExport
    participant FileSystem

    User->>PageInstanceExport: StartExport(sender, e)
    activate PageInstanceExport
    PageInstanceExport->>FileSystem: ModBase.CopyDirectory(Path.Combine(McInstance.PathInstance, PCL), Path.Combine(OverridesFolder, PCL))
    alt [IncludePCL] and [RELEASE]
        PageInstanceExport->>FileSystem: File.Copy(ModBase.ExePathWithName, Path.Combine(CacheFolder, Plain_Craft_Launcher_exe), true)
    end
    alt [IncludePCLCustom]
        PageInstanceExport->>FileSystem: ModBase.CopyDirectory(PCL_custom_source, PCL_custom_destination)
    end
    deactivate PageInstanceExport
Loading

File-Level Changes

Change Details Files
Convert a remaining VB-style conditional copy of the PCL executable to proper C# File.Copy usage within the export process.
  • Replace commented-out VB-style conditional copy block with C# single-line if statement
  • Use System.IO.File.Copy with ModBase.ExePathWithName and Path.Combine to build the destination path
  • Ensure existing destination file is overwritten by passing overwrite=true to File.Copy
  • Retain behavior behind the existing RELEASE conditional compilation directive
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceExport.xaml.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 - 我给出了一些整体层面的反馈:

  • #if RELEASE 代码块中,建议使用已有的 ModBase.CopyFile 辅助方法,而不是直接调用 File.Copy,以便在行为(日志记录、错误处理、权限)上与其他导出逻辑保持一致。
  • 为了与周围的 C# 代码风格保持一致,即使 if (IncludePCL) 的主体只有一条语句,也建议加上花括号。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Within the `#if RELEASE` block, consider using the existing `ModBase.CopyFile` helper instead of `File.Copy` directly to keep behavior (logging, error handling, permissions) consistent with the rest of the export logic.
- For consistency with surrounding C# style, wrap the `if (IncludePCL)` body in braces even though it is a single statement.

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

Hey - I've left some high level feedback:

  • Within the #if RELEASE block, consider using the existing ModBase.CopyFile helper instead of File.Copy directly to keep behavior (logging, error handling, permissions) consistent with the rest of the export logic.
  • For consistency with surrounding C# style, wrap the if (IncludePCL) body in braces even though it is a single statement.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Within the `#if RELEASE` block, consider using the existing `ModBase.CopyFile` helper instead of `File.Copy` directly to keep behavior (logging, error handling, permissions) consistent with the rest of the export logic.
- For consistency with surrounding C# style, wrap the `if (IncludePCL)` body in braces even though it is a single statement.

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.

Big-Cake-jpg
Big-Cake-jpg previously approved these changes May 17, 2026
@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels May 17, 2026
@Big-Cake-jpg Big-Cake-jpg merged commit f3fd186 into dev May 17, 2026
3 checks passed
@pcl-ce-automation pcl-ce-automation Bot added 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels May 17, 2026
@Big-Cake-jpg Big-Cake-jpg deleted the fix/CopyPCL branch May 17, 2026 11:35
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