-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Diagnostic for mapping null mismatch #602
Comments
If you add this, please make it possible to suppress this diagnostic for a single member. So that I can say "I know this, it's fine". |
Please, prioritize this issue. I would find it very useful and development without it is not compile time safe. |
In my opinion, Mapperly is compile-safe without this feature, as all generated code is type-safe and provides diagnostics for invalid mappings. I can still understand your need for this feature, as it would definitely be a nice addition. |
Thanks for the quick reply! I'm sorry, I didn't mean to say that "the code that Mapperly produces is not compile-time safe" in any way. What I meant is that:
After writing my previous comment I discovered that in the 4.0.0-next.1 preview documentation there is a new diagnostic, Thanks again! |
We definitely want to implement this diagnostic, it's just not on top of our priority list 😊 |
Okay, I understand. Thanks anyway! ❤️ |
Hey @latonz, I would like to work on this, could you assign me? 😄 |
@F1nn-T are you still working on this? |
Yes, just didn't had the time yet to finish. |
I don't mean to hijack the issue but this is something I would really like and progress seems to have stalled, so I have made an initial PR for this issue: #1592 [MapProperty(nameof(A.Value), nameof(B.Value), Use = nameof(MapString)]
public partial B Map(A source);
[UserMapping(Default = false)]
private string MapString(string? source)
=> source ?? "(null)";
""",
"""
class A
{
public string? Value { get; }
public string? Value2 { get; }
}
""",
"""
class B
{
public string Value { set; }
public string Value2 { set; }
} So before continuing, would it be possible to get a quick review just to see if I'm looking in the right place to add this feature? If so I will update the existing tests and try to see if I can add an option to disable this check per property too as requested earlier in this discussion |
Feature got implemented by @jorisBarkema in #1592 / #1612. I created #1613 to support an API to disable the diagnostics for given members. |
Emit a diagnostic if the source is nullable but the target isn't. Default severity should be info.
Proposed message:
Mapping the nullable source property {0} of {1} to the target property {2} of {3} which is not nullable
Relates #375
The text was updated successfully, but these errors were encountered: