Repository navigation
Ignore nullable property does warning CS8603 #520
Description
Activity
Any fix for this? How do you ignore a property that is nullable?
getting same issue.
.Ignore(dest => dest.AccountNumber) //fails/warns with CS8603 when property is nullable.
.Ignore("AccountNumber") //works fine. How expensive is this? Does this not use reflection?
Hi @vzalamea
.Ignore(dest => dest.AccountNumber) == .Ignore("AccountNumber").Ignore(dest => dest.AccountNumber)
This is a helper that gets the Name of the property from the Expression, not the value of that Expression and is more resistant to refactoring in IDE.Hi @vzalamea
.Ignore(dest => dest.AccountNumber) == .Ignore("AccountNumber").Ignore(dest => dest.AccountNumber)This is a helper that gets the Name of the property from the Expression, not the value of that Expression and is more resistant to refactoring in IDE.the problem is when I have <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

If I treat it as just a warning, the code compiles fine and behaves as expected. So I'm not sure why "d.AccountNumber" is being evaluated and not just used to get the property name.
It occurs because Expressions usually using to obtain the Values of property.
This is precisely what the compiler warns you about. If you try to get the value of this property, you might get null instead of a string.The fix for this case should be simple, I'll see what I can do.
Reacted by Vince Zalamea and Julien JReacted by Rami Abughazaleh- linked a pull request that will close this issueFix #520 - Ignore() settings setter potential Nullable warning #991
on Jun 24, 2026 Thank you, @DocSvartz .
It seems this made it into the v10.0.10 release.

.Net 7.0 with nullable enabled
I think that signature of Ignore method need to be
public TypeAdapterSetter<TSource, TDestination> Ignore(params Expression<Func<TDestination, object?>>[] members);