Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Unable to map classes with generics

オープン
#724 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp
領域
tooling

調査の方向性

ファイル、テスト、エントリポイントは指定されていません。まず、ここで説明されている Audit、LogData サブクラス、DTO、Include、IgnoreNonMapped の設定を使って、報告されたコンパイル時およびランタイムの失敗を再現してください。両方のジェネリック mapping ケースについて、期待される動作と焦点を絞った修正が確立されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

configuration problem

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 AuditDTO had 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's config.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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MapsterMapper/Mapster のほかの issue

MapsterMapper/Mapster の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。