Conversation
There was a problem hiding this comment.
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 missingusing System;,using System.IO;,using System.Collections.Generic;, andusing System.Linq;. Add these directives to ensure it compiles.
using System.Security.Cryptography;
| if (!Directory.Exists(dstOutputFolder)) | ||
| { | ||
| Directory.CreateDirectory(dstOutputFolder); | ||
| Directory.CreateDirectory(dstOutputFolder ?? DefaultDstFolder); |
There was a problem hiding this comment.
[nitpick] The null-coalescing here is redundant since dstOutputFolder is always non-null after initialization. Simplify to Directory.CreateDirectory(dstOutputFolder);.
| Directory.CreateDirectory(dstOutputFolder ?? DefaultDstFolder); | |
| Directory.CreateDirectory(dstOutputFolder); |
| { | ||
| // 构建目标文件的完整路径 | ||
| string targetFilePath = Path.Combine(dstOutputFolder, file[(srcMetadataFolder.Length + 1)..]); | ||
| if (file.EndsWith("metadata.xml")) continue; // 已处理 |
There was a problem hiding this comment.
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.
| if (file.EndsWith("metadata.xml")) continue; // 已处理 | |
| if (Path.GetFileName(file).Equals("metadata.xml", StringComparison.OrdinalIgnoreCase)) continue; // 已处理 |
| // 4. 验证处理后的文件 | ||
| try | ||
| { | ||
| var verifiedMetadata = Metadata.LoadFromFile(metadataPath); |
There was a problem hiding this comment.
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.
| var verifiedMetadata = Metadata.LoadFromFile(metadataPath); | |
| string processedMetadataPath = Path.Combine(dstOutputFolder, "metadata.xml"); | |
| var verifiedMetadata = Metadata.LoadFromFile(processedMetadataPath); |
| string targetFilePath = Path.Combine(dstOutputFolder ?? DefaultDstFolder, | ||
| file[(srcMetadataFolder.Length + 1)..]); |
There was a problem hiding this comment.
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.
| string targetFilePath = Path.Combine(dstOutputFolder ?? DefaultDstFolder, | |
| file[(srcMetadataFolder.Length + 1)..]); | |
| string relativePath = Path.GetRelativePath(srcMetadataFolder, file); | |
| string targetFilePath = Path.Combine(dstOutputFolder ?? DefaultDstFolder, relativePath); |
No description provided.