b75439c以"命令行是多余的"为由把读取改成 FileStream+StreamReader,是错误前提: 项目存在无法用标准文件 I/O 读取的加密 txt/钻带文件(CLAUDE.md "Encrypted file reading"、 Docs/readme.md "读取加密钻带(使用cmd命令type读取)"、 Docs/刀具列表拖动排序功能说明.md "加密文件:使用 cmd 命令读取"均有记录), 该改动会导致这些文件读取失败。本次回退。 改动: - 还原 CommandTypeFileReader.cs:cmd.exe /d /c type(ANSI/936 解码), 失败时退出码与 stderr 保留在异常消息里 - 删除 ForbiddenPathChars 与两处字符校验(本次报错根因): ( ) & ^ @ 空格在双引号内对 type 安全,黑名单只会误伤 (D2-f)、(1) 等正常文件名 - 保留"非空路径""文件存在"校验与 ReadAllText(path, encoding) 重载 - 删除 AnsiFileReader.cs,15 处调用点改回 - CLAUDE.md / .trellis/spec/:恢复"加密文件必须用 cmd type"的说明, 并标注为不可优化掉的硬约束(含b75439c反例) 验证:demo_drl 全部 36 个文件与2335894实现逐字符一致、行数一致; 含 ( ) & 空格路径实测可读(旧黑名单实现抛"文件路径包含不允许的命令行特殊字符"); cmd 失败消息含退出码与 stderr;dotnet build -p:Platform=x86 0 错误, 警告集与 HEAD 基线完全一致。
68 lines
3.5 KiB
Markdown
68 lines
3.5 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
DrillTools (钻带处理工具) is a Windows desktop application for processing PCB drill tape files. It parses drill tape data, displays tool information (tool number, diameter, hole count, parameters), and supports reordering tools with various sorting methods.
|
|
|
|
## Build & Run
|
|
|
|
```bash
|
|
dotnet build # Build the project
|
|
dotnet build -c Release # Build in Release mode
|
|
dotnet publish # Publish as single-file exe (win-x86)
|
|
```
|
|
|
|
Target: .NET 6.0, WPF, x86 only. No external NuGet dependencies.
|
|
|
|
No test framework is configured. Do not write unit tests for this project.
|
|
|
|
## Architecture
|
|
|
|
**MVVM pattern** with three windows:
|
|
|
|
- **MainWindow** — primary UI for loading, viewing, and reordering drill tape tools
|
|
- **ToolDetailWindow** — displays detailed tool parameters
|
|
- **ToolReorderConfirmationWindow** — confirmation dialog for reorder operations
|
|
|
|
**Key files:**
|
|
|
|
| File | Role |
|
|
|---|---|
|
|
| `MainWindowViewModel.cs` (~2400 lines) | Central business logic: tool management, drill tape parsing/generation, sort seed management, reference tape comparison |
|
|
| `DrillTapeProcessor.cs` | Core drill tape parsing engine (`DrillTools.Integration` namespace) |
|
|
| `ToolItem.cs` | Data model for drill tools (implements `INotifyPropertyChanged`) |
|
|
| `SlotHoleCalculator.cs` | Geometry calculations for slot hole counts and positions |
|
|
| `DragDropHelper.cs` | WPF ListView drag-drop with visual insertion indicator |
|
|
|
|
**Namespaces:** `DrillTools` (UI/models), `DrillTools.Integration` (parsing logic).
|
|
|
|
## Drill Tape Format
|
|
|
|
The app parses a specific PCB drill tape format:
|
|
|
|
```
|
|
M48 ← Header start
|
|
T01C0.799H05000Z+0.000S060.00 ← Tool definitions (Txx=tool#, C=diameter, rest=machine params)
|
|
T02C0.656H01500Z+0.150S070.00
|
|
% ← Header end / data start
|
|
T01 ← Active tool
|
|
X-167525Y013500 ← Hole coordinates
|
|
X-069659Y016450G85X-094159Y016450 ← Slot hole (start G85 end)
|
|
M30 ← End of file
|
|
```
|
|
|
|
Supported file extensions: `.txt`, `.drl`, `.dr2`, `.dpin`
|
|
|
|
**Tool types by diameter suffix digit:** 0/8/9=Drill, 1=Slot, 2/6=EA Slot, 3=Dust Slot, 4=Deburr, 5=NonStandard, 7=Special.
|
|
|
|
## Important Technical Details
|
|
|
|
- **File encoding**: ANSI/GB2312 (code page 936) — drill tape files use this encoding, not UTF-8
|
|
- **Encrypted file reading**: Uses `cmd.exe /c type` to read drill tape files (some files are "encrypted" and cannot be read directly via standard file I/O). Drill tape / parameter files are read through `CommandTypeFileReader` — **do not "optimize" this into standard file I/O (`File.ReadAllText` / `FileStream` / `StreamReader`)**: that was tried in `b75439c` (2026-09-20) and broke reading of encrypted files, and was reverted. Paths are no longer filtered by a character blacklist: `(`, `)`, `&`, `^`, `@` and spaces are safe inside the quoted `type` argument, and the old blacklist only produced false positives on normal file names such as `(D2-f)` and `(1)`.
|
|
- **Slot hole calculation**: Uses CAM350 standard tolerance (0.0127mm) for computing hole counts along slot paths
|
|
- **Backup strategy**: Creates `.bak` files when saving modified drill tape data
|
|
- **Command-line support**: App accepts a file path argument to auto-load a drill tape file on startup
|
|
- **Documentation**: All docs under `Docs/` are in Chinese (Simplified). The UI is also in Chinese.
|