Unable to map classes with generics
まだ誰も着手していません。
評価
調査の方向性
ファイル、テスト、エントリポイントは指定されていません。まず、ここで説明されている Audit、LogData サブクラス、DTO、Include、IgnoreNonMapped の設定を使って、報告されたコンパイル時およびランタイムの失敗を再現してください。両方のジェネリック mapping ケースについて、期待される動作と焦点を絞った修正が確立されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I would want to map a class structure for logs. The main class is a generic class Audit<T> where T is class LogData or a subclass it.
DTO would have a simple structure with AuditDTO and property of type LogDataDTO, that object has all the possible subclass properties united in it.
- My initial issues occurred at compile time as
CompileException.
If my configuration has
config.NewConfig<LogData, LogDataDTO>()<-- with all base class properties mapped plus
.IgnoreNonMapped(true)
.Include<LogDataSubclass, LogDataDTO>()<-- for all subclass of LogData
and
config.NewConfig<LogDataSubclass, LogDataDTO>() <-- with all the specific subclass properties mapped plus
.IgnoreNonMapped(true)
then it would complain about LogDataDTO not having a corresponding source member mapped or ignored: SOME properties of LogDataSubclasses' - but weird enough not all of them. If I added to the LogData baseclass config explicitly the .Ignore(dest => dest.ProblematicSubclassProp) then that would solve the issue.
- Second issue occurred afterward at runtime. The
AuditDTOhad the same exception that its properties, other than the LogData, are not mapped or ignored. Adding an explicit config for mapping seems trickier as it does not seem to work with invariance:
if there'sconfig.NewConfig<Audit<LogData>(), AuditDTO>(), or any other type of<Audit<LogDataSubclass>, AuditDTO>then the source type causing the error is referred to as<IAudit<ILogData>>. (Conventional interfaces)
I have the impression that i heavily overcomplicate the config and not using (misusing) some methods here... IgnoreNonMapped is definetely not working as expected and makes this whole declarartion redundant.
- 主要言語
- C#
- スター
- 5.2k
- フォーク
- 411
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MapsterMapper/Mapster のほかの issue
-
.NET Matrixオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MapsterMapper/Mapster#1003 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
MapsterMapper/Mapster#1024 · コメント 1 件 ·
-
[Mapster Tool] Add support for global:: to disambiguate type names in generated mappers対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンimprovement
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
MapsterMapper/Mapster#1020 · コメント 5 件 ·
-
Mapster.Tool - PropertySettingBuilder.Map(member, mapFunc, targetPropertyName) method is not working as expected!対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
MapsterMapper/Mapster#1017 · コメント 6 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
MapsterMapper/Mapster#1007 · コメント 5 件 ·
MapsterMapper/Mapster の issue をすべて見る
似ている issue
-
alerts bug effort:S P2
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nightscout/nocturne#2511 ·
メンテナーはふだん 1 日以内に返信
-
feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
stripe/stripe-dotnet#3484 ·
メンテナーはふだん 2 日以内に返信
-
bug mcp misleading small
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
accessibility help wanted macos
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
dorlugasigal/annotator#42 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
AvaloniaUI/Avalonia#22568 ·
メンテナーはふだん 2 日以内に返信