Unable to map classes with generics
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Không có tệp, kiểm thử hoặc entry point nào được nêu. Hãy bắt đầu bằng cách tái hiện các lỗi lúc biên dịch và lúc runtime đã báo cáo bằng Audit, các lớp con của LogData, DTO, Include và các cấu hình IgnoreNonMapped được mô tả ở đây; được xem là hoàn tất khi hành vi mong đợi và một bản sửa tập trung đã được xác lập cho cả hai trường hợp mapping generic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 5.2k
- Fork
- 411
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MapsterMapper/Mapster
-
.NET MatrixĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MapsterMapper/Mapster#1003 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
MapsterMapper/Mapster#1024 · 1 bình luận ·
-
[Mapster Tool] Add support for global:: to disambiguate type names in generated mappersCó thể đã có người làm @DocSvartz đã nhận 3 ngày trước. Đang mởimprovement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
MapsterMapper/Mapster#1020 · 5 bình luận ·
-
Mapster.Tool - PropertySettingBuilder.Map(member, mapFunc, targetPropertyName) method is not working as expected!Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
MapsterMapper/Mapster#1017 · 6 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
MapsterMapper/Mapster#1007 · 5 bình luận ·
Tất cả issue của MapsterMapper/Mapster
Issue tương tự
-
area: client bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug mcp misleading small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Platform: Android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/sentry-dotnet#5764 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/SimpleL7Proxy#287 ·
Maintainer thường phản hồi trong vòng 1 ngày