Unable to map classes with generics
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
No se especifican archivos, pruebas ni puntos de entrada. Empieza reproduciendo los fallos en tiempo de compilación y de ejecución descritos aquí con Audit, las subclases de LogData, los DTOs y las configuraciones Include e IgnoreNonMapped; se considera terminado cuando el comportamiento esperado y una corrección específica estén establecidos para ambos casos de mapping genérico.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 5.2k
- Forks
- 411
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MapsterMapper/Mapster
-
.NET MatrixAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
MapsterMapper/Mapster#1003 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
MapsterMapper/Mapster#1024 · 1 comentario ·
-
[Mapster Tool] Add support for global:: to disambiguate type names in generated mappersPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoimprovement
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
MapsterMapper/Mapster#1020 · 5 comentarios ·
-
Mapster.Tool - PropertySettingBuilder.Map(member, mapFunc, targetPropertyName) method is not working as expected!Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
MapsterMapper/Mapster#1017 · 6 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 57/100
MapsterMapper/Mapster#1007 · 5 comentarios ·
Todos los issues de MapsterMapper/Mapster
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Nimblesite/SharpLsp#468 ·
Los mantenedores suelen responder en 1 día
-
V4 alert-rule reads have no scope gate, so any authenticated credential can list alert rulesAbiertoalerts bug effort:S P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
nightscout/nocturne#2511 ·
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
feature-request
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
stripe/stripe-dotnet#3484 ·
Los mantenedores suelen responder en 2 días
-
bug mcp misleading small
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día