Unable to map classes with generics
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Non sono indicati file, test o punti di ingresso. Inizia riproducendo gli errori in fase di compilazione e di runtime descritti qui con Audit, le sottoclassi di LogData, i DTO e le configurazioni Include e IgnoreNonMapped descritte qui; il lavoro è completato quando il comportamento previsto e una correzione mirata sono stabiliti per entrambi i casi di mapping generico.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C#
- Stelle
- 5.2k
- Fork
- 411
- Merge medio
- 1g 8h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MapsterMapper/Mapster
-
.NET MatrixAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
MapsterMapper/Mapster#1003 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
MapsterMapper/Mapster#1024 · 1 commento ·
-
[Mapster Tool] Add support for global:: to disambiguate type names in generated mappersForse già presa @DocSvartz l’ha presa 3 giorni fa. Apertaimprovement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
MapsterMapper/Mapster#1020 · 5 commenti ·
-
Mapster.Tool - PropertySettingBuilder.Map(member, mapFunc, targetPropertyName) method is not working as expected!Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
MapsterMapper/Mapster#1017 · 6 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 57/100
MapsterMapper/Mapster#1007 · 5 commenti ·
Tutte le issue di MapsterMapper/Mapster
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
[Bug]: Revit selector reads process ids 2000-2099 as years (flaky AgentClientTests.AYearOrAProcessIdSelectsTheHost)Forse già presa @Wurschdhaud l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
pyrevitlabs/pyRevit#3817 ·
I maintainer di solito rispondono entro 1 giorno
-
bug effort:S P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nightscout/nocturne#2449 ·
I maintainer di solito rispondono entro 1 giorno
-
audit:1 bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
NethermindEth/dotnet-libp2p#395 ·
I maintainer di solito rispondono entro 1 giorno
-
area: client bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno