Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

"IgnoreIf" doesn't work for records

未关闭
#1,007 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
57/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp
领域
backend

调研方向

首先,在 Mapster 10.0.11 中重现报告的 mapper 代码片段,并将生成的表达式与版本 7 进行比较。重点关注 records 的 IgnoreIf 处理,并通过回归测试验证修复,测试应表明生成的 mapping 遵循 key 检查,并在 key 缺失时保持 BoxPost 不变。

由索引模型根据 Issue 内容生成。

描述

Hi. In version 10.0.11, "IgnoreIf" doesn't work as it did in version 7... My mapper is written like this:

.Map(ask => ask.BoxPost, crm => crm.GetValue<AddressEntity, string?>(nameof(AddressEntity.BoxPost)))
.IgnoreIf((d, ask) => !d.ContainsKey<AddressEntity>(nameof(AddressEntity.BoxPost)), nameof(AddressEntity.BoxPost))

previously, in version 7, the following mapper code was generated:

.If (
    .Call ReForm.Ism.Core.Serialization.Extensions.JsonObjectExtension.ContainsKey(
        $var1,
        "BoxPost")
) {
    .Block() {
        $result.BoxPost = .Invoke (.Lambda #Lambda2<System.Func`3[System.String,System.Nullable`1[System.Decimal],System.Nullable`1[System.Decimal]]>)(
.Call ReForm.Ism.Core.Serialization.Extensions.JsonObjectExtension.GetValue(
    $var1,
    "BoxPost"),
$result.BoxPost)
    }
} .Else {
    .Default(System.Void)
};

and now I get this:

BoxPost = .Invoke (.Lambda #Lambda2<System.Func`2[System.String,System.Nullable`1[System.Decimal]]>)(.Call ReForm.Ism.Core.Serialization.Extensions.JsonObjectExtension.GetValue(
                    $var1,
                    "BoxPost")),

It turns out that the presence of "IgnoreIf" does not change anything.

主要语言
C#
星标
5.2k
派生
409
平均合并
3 天 4 小时
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MapsterMapper/Mapster 的其他 Issue

查看 MapsterMapper/Mapster 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。