Skip to content

Remove record converter#116

Merged
Soar360 merged 3 commits into
mainfrom
remove-record-converter
May 20, 2026
Merged

Remove record converter#116
Soar360 merged 3 commits into
mainfrom
remove-record-converter

Conversation

@Soar360

@Soar360 Soar360 commented May 20, 2026

Copy link
Copy Markdown
Contributor

This pull request primarily restructures the namespaces and refactors the mapping infrastructure of the codebase, with some deletions of unused or redundant classes. The changes aim to improve code organization, clarify responsibilities, and simplify the mapping logic by removing custom converter registration and related complexity.

Namespace and File Organization Improvements:

  • Moved mapping-related attributes (RecordAttribute, RecordColumnNameAttribute, RecordColumnStorageAttribute) into the LuYao.Data.Attributes namespace for better separation of concerns. [1] [2] [3]
  • Moved binary-related classes (BinaryPayloadHeader, RecordBinaryPayloadCodec, RecordPayloadCompression) into the LuYao.Data.Binary namespace, and JSON converters into LuYao.Data.Json, improving modularity. [1] [2] [3] [4] [5]

Mapping Infrastructure Refactoring:

  • Renamed and moved mapping classes from the Meta namespace to Mapping, including ColumnNameResolver and RecordMappingContext, and moved RecordMappingOptions to LuYao.Data.Mapping. [1] [2] [3]
  • Removed support for registering custom type converters in RecordMappingOptions and related converter resolution logic in RecordMappingContext. Now, unsupported types directly trigger error handling, simplifying the mapping process. [1] [2] [3] [4] [5]

Code Cleanup:

  • Deleted unused or redundant converter classes, such as XConverter and StringToInt32Converter, to reduce maintenance overhead. [1] [2]
  • Removed the generic XCopy<TSource, TTarget> class, streamlining the codebase by eliminating unused copying utilities.
  • Minor cleanup of unnecessary using directives.

These changes collectively improve code clarity, maintainability, and modularity by enforcing stricter boundaries between concerns and simplifying the mapping logic.

Soar360 added 3 commits May 20, 2026 14:41
将 ColumnNameResolver、RecordMappingContext、RecordMappingOptions 等与 DTO/RecordTable 映射相关的核心类型从 LuYao.Data.Meta 命名空间迁移到 LuYao.Data.Mapping,并同步调整所有相关 using 路径。移除 RecordColumnStorageTarget 中未使用的 String、Bytes 枚举值,仅保留 Skip。实现代码和注释未做实质性更改,保持英文注释规范。
本次提交将 Attribute、Binary、Json 相关类分别迁移到 LuYao.Data.Attributes、LuYao.Data.Binary、LuYao.Data.Json 命名空间,并同步调整相关文件的 using 引用。此举提升了代码的模块化和可维护性。
Copilot AI review requested due to automatic review settings May 20, 2026 07:00
@Soar360 Soar360 merged commit 89058b8 into main May 20, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors the Record mapping infrastructure by removing custom converter registration and restructuring namespaces to better separate mapping, attributes, binary payload, and JSON concerns.

Changes:

  • Moved mapping-related attributes into LuYao.Data.Attributes, and binary/JSON helpers into LuYao.Data.Binary / LuYao.Data.Json.
  • Simplified mapping by removing RecordConverter / DefaultRecordConverter and related converter resolution paths.
  • Updated unit tests and removed tests tied to deleted converter/copying utilities.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/LuYao.Common.UnitTests/Data/RecordMappingOptionsTests.cs Removes converter-related tests and updates usings for new namespaces.
tests/LuYao.Common.UnitTests/Data/RecordJsonConverterTests.cs Updates usings to new Binary/Json namespaces.
tests/LuYao.Common.UnitTests/Data/Meta/XCopyGenericTests.cs Removes tests for deleted XCopy<TSource,TTarget>.
src/LuYao.Common/Data/UnsupportedTypeHandling.cs Removes converter-based handling modes, leaving Skip/Throw.
src/LuYao.Common/Data/RecordTable/Binary.cs Updates references to binary payload types via LuYao.Data.Binary.
src/LuYao.Common/Data/RecordSet/Binary.cs Updates references to binary payload types via LuYao.Data.Binary.
src/LuYao.Common/Data/RecordRow/Merge.cs Updates mapping references to LuYao.Data.Mapping.
src/LuYao.Common/Data/RecordConverter.cs Deletes converter base types.
src/LuYao.Common/Data/RecordColumnStorageTarget.cs Removes non-skip storage targets.
src/LuYao.Common/Data/RecordColumnCollection.cs Updates mapping references to LuYao.Data.Mapping.
src/LuYao.Common/Data/Meta/DefaultRecordConverter.cs Deletes the built-in fallback converter.
src/LuYao.Common/Data/Mapping/XCopy.cs Removes XCopy<TSource,TTarget> and keeps mapping centered around RecordRow/DTO mapping.
src/LuYao.Common/Data/Mapping/XConverter.cs Deletes unused converter abstraction.
src/LuYao.Common/Data/Mapping/RecordMappingOptions.cs Moves options into LuYao.Data.Mapping and removes converter registration API.
src/LuYao.Common/Data/Mapping/RecordMappingContext.cs Removes converter resolution and enforces stricter mapping behavior.
src/LuYao.Common/Data/Mapping/Converters/StringToInt32Converter.cs Deletes an unfinished converter stub.
src/LuYao.Common/Data/Mapping/ColumnNameResolver.cs Moves resolver into LuYao.Data.Mapping and updates attribute usage.
src/LuYao.Common/Data/Json/RecordTableJsonConverter.cs Moves JSON converter into LuYao.Data.Json and updates binary dependencies.
src/LuYao.Common/Data/Json/RecordSetJsonConverter.cs Moves JSON converter into LuYao.Data.Json and updates binary dependencies.
src/LuYao.Common/Data/Binary/RecordPayloadCompression.cs Moves into LuYao.Data.Binary.
src/LuYao.Common/Data/Binary/RecordBinaryPayloadCodec.cs Moves into LuYao.Data.Binary.
src/LuYao.Common/Data/Binary/BinaryPayloadHeader.cs Moves into LuYao.Data.Binary.
src/LuYao.Common/Data/Attributes/RecordColumnStorageAttribute.cs Moves into LuYao.Data.Attributes.
src/LuYao.Common/Data/Attributes/RecordColumnNameAttribute.cs Moves into LuYao.Data.Attributes.
src/LuYao.Common/Data/Attributes/RecordAttribute.cs Moves into LuYao.Data.Attributes.
Comments suppressed due to low confidence (3)

src/LuYao.Common/Data/Mapping/RecordMappingContext.cs:53

  • MapDtoToRow writes into an existing column whenever the property type is a supported column type, but it does not verify that the existing column type matches the property type. Since RecordColumn.Set can coerce values via Valid.To, this can silently write converted values into a mismatched column schema and later make round-tripping back to DTO fail (MapRowToDto requires exact type match). Consider requiring col.Type == prop.Type here as well, or explicitly handling type mismatches according to the mapping options.

This issue also appears on line 110 of the same file.
src/LuYao.Common/Data/Mapping/RecordMappingContext.cs:112

  • This NotSupportedException message is used both when the property type is unsupported and when the column/property types don't match. In the mismatch case, saying the property type "is not supported" is misleading. Consider including both col.Type and prop.Type in the message and/or using a different message for type mismatch vs unsupported type.
    src/LuYao.Common/Data/Mapping/RecordMappingOptions.cs:7
  • After removing custom converter support from RecordMappingOptions, the XML docs in this file still reference the removed AddConverter API (and the cref for RecordColumnNameAttribute appears to use an outdated namespace). Please update the documentation so it matches the current public surface and resolves cleanly when generating XML docs.

Comment on lines 9 to 13
/// <summary>
/// 跳过该属性,不在 RecordTable 中创建对应的列。
/// </summary>
Skip = 0,

/// <summary>
/// 将属性值转换为 <see cref="string"/> 后存储。
/// 必须在 <see cref="RecordMappingOptions"/> 中注册该属性类型对应的 <see cref="RecordConverter"/>,否则将抛出异常。
/// </summary>
String = 1,

/// <summary>
/// 将属性值转换为 <see cref="byte"/>[] 后存储。
/// 必须在 <see cref="RecordMappingOptions"/> 中注册该属性类型对应的 <see cref="RecordConverter"/>,否则将抛出异常。
/// </summary>
Bytes = 2,
Skip = 0
}
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