wanshenmean
2026-03-13 4e60cd8649c3c19582ae560515cad00436587a2e
分支
用户 wanshenmean <cathay_xy@163.com>
星期五, 三月 13, 2026 13:36 +0800
提交者 wanshenmean <cathay_xy@163.com>
星期五, 三月 13, 2026 13:36 +0800
提交4e60cd8649c3c19582ae560515cad00436587a2e
目录 52567ace3cb09f19a283315c5180d4d0215c6c0f 目录 | zip | gz
上一版本 e5c50f215156a213fa39abef2de477db98b75969 查看 | 对比
fix: improve MemoryStore code quality and error handling

Critical fixes:
- ConvertFromBytes now throws NotSupportedException for unsupported types instead of returning default
- Removed string type handling from generic methods (unreachable with struct constraint)
- Updated to use IsNullOrWhiteSpace instead of IsNullOrEmpty for address validation

Major fixes:
- ParseAddress now wraps FormatException/OverflowException with context
- Import now validates data lengths match region sizes before writing
- Added explicit validation that length is non-zero in ReadBytes
- Added comprehensive XML documentation for all public methods
- Documented GetRegion returns mutable references requiring lifecycle coordination
- Documented Export is expensive and should be used sparingly
- Documented DBRegion auto-creation behavior in Import/Export

Improvements:
- Fixed endianness handling to use big-endian consistently (S7 PLC standard)
- Added support for uint and byte types in conversion methods
- Improved error messages with detailed context
- Enhanced ExportDBRegion to handle missing DB blocks gracefully

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
已修改1个文件
264 ■■■■ 文件已修改
Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Memory/MemoryStore.cs 264 ●●●● 对比 | 查看 | 原始文档 | blame | 历史