Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning not thrown for source nested property with no mapping #1727

Open
ShahryarSaljoughi opened this issue Feb 21, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@ShahryarSaljoughi
Copy link

Describe the bug
I expect to see a warning if a property from the source of mapping is not mapped to anything.
Here is my mapping declaration:

[MapProperty(
     source: nameof(VoucherCreationRequest.CustomersConditions),
     target: nameof(@VoucherDefinition.CriteriaContainer.CustomerPropertiesCriteria))]
public static partial void PatchInternal(this VoucherCreationRequest source, VoucherDefinition destination);

public static partial CustomerPropertiesCriteria MapCustomerConditionsDtoToCriteria(this CustomersConditionsDto source);

And these are the types of source and destination:

public class VoucherCreationRequest
{
    public VoucherBranchCriteriaDto? BranchCriteria { get; set; }
    public MinimumInvoicePriceCriteriaDto? MinimumInvoicePriceCriteria { get; set; }
    public CustomersConditionsDto CustomersConditions { get; set; } = new ();
}

public abstract class VoucherDefinition
{
    public CriteriaContainer? CriteriaContainer { get; set; } = new();
}

public class CriteriaContainer: IDbEntity
{
    public MinimumInvoicePriceCriteria? MinimumInvoicePriceCriteria { get; set; }
    public VoucherBranchCriteria? VoucherBranchCriteria { get; set; }
    public CustomerPropertiesCriteria? CustomerPropertiesCriteria { get; set; }

    // This one is not mapped
    public CustomerCalendarBasedCriteria? CustomerCalendarBasedCriterionData { get; set; }

}

public class CustomersConditionsDto: CustomersFilterDto
{
    public DateTimeOffset? FromSpouseBirthDateTime { get; set; }
    public DateTimeOffset? ToSpouseBirthDateTime { get; set; }
}

public class CustomersFilterDto
{
    ...
    public PartialDateFilter? PartialBirthDateFilter { get; set; }
    public PartialDateFilter? PartialMarriageDateFilter { get; set; }
    public PartialDateFilter? PartialSpouseBirthDateFilter { get; set; }
}

I want to map VoucherCreationRequest.CustomersConditions to VoucherDefinition.CriteriaContainer.CustomerPropertiesCriteria and also I want to map from the same ``VoucherCreationRequest.CustomersConditionstoVoucherDefinition.CriteriaContainer.CustomerCalendarBasedCriterionData`.
Nothing is mapped to `VoucherDefinition.CriteriaContainer.CustomerCalendarBasedCriteria`. Hence some warning regarding that is supposed to be thrown but currently is not.

The only relevant warning I get is about the PartialBirthDateFilter property on source not being mapped to any member on CustomerPropertiesCriteria. Nothing is warned about CustomerCalendarBasedCriteria.

The main reason for me to use Mapperly, is the warnings that help prevent any piece of data being lost during conversions by mistake. So we really need those warnings to appear.

@ShahryarSaljoughi ShahryarSaljoughi added the bug Something isn't working label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant