Skip to content

Conversation

@mrbbbaixue
Copy link
Member

No description provided.

@mrbbbaixue mrbbbaixue requested a review from Copilot July 4, 2025 01:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the project to the “Standard 0.9” metadata pipeline by fixing script paths, refactoring the CLI runner, and adding a full XML metadata processor.

  • build.sh and csproj: fix output path casing and remove stray BOM
  • Program.cs: introduce default folder constants, argument parsing, folder creation, Chinese logs, and metadata processing steps
  • Metadata.cs: add a comprehensive XML loader, validator, variable replacer, and compiler
  • README & XML files: switch to a unified <Metadata> root, clarify variable syntax, and reorganize module includes

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
build.sh Updated --dst path to ./Output
Ra3.BattleNet.Metadata/Ra3.BattleNet.Metadata.csproj Removed leading BOM character
Ra3.BattleNet.Metadata/Program.cs Refactored main runner, added CLI args and metadata workflow
Ra3.BattleNet.Metadata/Metadata.cs New metadata parsing, validation, variable replacement, hashing
README.md Expanded module docs, updated inline variable examples
Metadata/**/*.xml Converted roots to <Metadata>, restructured includes
Comments suppressed due to low confidence (1)

Ra3.BattleNet.Metadata/Metadata.cs:1

  • This file references types from System, System.IO, System.Collections.Generic, and LINQ extension methods but is missing using System;, using System.IO;, using System.Collections.Generic;, and using System.Linq;. Add these directives to ensure it compiles.
using System.Security.Cryptography;

if (!Directory.Exists(dstOutputFolder))
{
Directory.CreateDirectory(dstOutputFolder);
Directory.CreateDirectory(dstOutputFolder ?? DefaultDstFolder);
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

[nitpick] The null-coalescing here is redundant since dstOutputFolder is always non-null after initialization. Simplify to Directory.CreateDirectory(dstOutputFolder);.

Suggested change
Directory.CreateDirectory(dstOutputFolder ?? DefaultDstFolder);
Directory.CreateDirectory(dstOutputFolder);

Copilot uses AI. Check for mistakes.
{
// 构建目标文件的完整路径
string targetFilePath = Path.Combine(dstOutputFolder, file[(srcMetadataFolder.Length + 1)..]);
if (file.EndsWith("metadata.xml")) continue; // 已处理
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

Using EndsWith on a full path can be brittle. Consider Path.GetFileName(file).Equals("metadata.xml", StringComparison.OrdinalIgnoreCase) to more reliably skip the metadata file.

Suggested change
if (file.EndsWith("metadata.xml")) continue; // 已处理
if (Path.GetFileName(file).Equals("metadata.xml", StringComparison.OrdinalIgnoreCase)) continue; // 已处理

Copilot uses AI. Check for mistakes.
// 4. 验证处理后的文件
try
{
var verifiedMetadata = Metadata.LoadFromFile(metadataPath);
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

This reloads the original source metadata.xml instead of the processed copy in the output folder. To verify the build output, load from Path.Combine(dstOutputFolder, "metadata.xml") instead.

Suggested change
var verifiedMetadata = Metadata.LoadFromFile(metadataPath);
string processedMetadataPath = Path.Combine(dstOutputFolder, "metadata.xml");
var verifiedMetadata = Metadata.LoadFromFile(processedMetadataPath);

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +62
string targetFilePath = Path.Combine(dstOutputFolder ?? DefaultDstFolder,
file[(srcMetadataFolder.Length + 1)..]);
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

Manual slicing of the full path can break if folder separators or trailing slashes change. Use Path.GetRelativePath(srcMetadataFolder, file) to compute the relative path robustly.

Suggested change
string targetFilePath = Path.Combine(dstOutputFolder ?? DefaultDstFolder,
file[(srcMetadataFolder.Length + 1)..]);
string relativePath = Path.GetRelativePath(srcMetadataFolder, file);
string targetFilePath = Path.Combine(dstOutputFolder ?? DefaultDstFolder, relativePath);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants