You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicstructDest{publicstringName{get;set;}publicstring?NullableString{get;set;}}publicstructSource{publicstringName{get;set;}}publicclassMapping:IRegister{publicvoidRegister(TypeAdapterConfigconfig){config.NewConfig<Source,Dest>().Ignore(d =>d.NullableString);// this string a got a warning message CS8603: Possible null reference return}}
I think that signature of Ignore method need to be public TypeAdapterSetter<TSource, TDestination> Ignore(params Expression<Func<TDestination, object?>>[] members);
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.
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.
Activity
nwoolls commentedon Nov 29, 2024
Any fix for this? How do you ignore a property that is nullable?
DocSvartz commentedon Jan 23, 2025
@andrerav As far as I understand, this is used to get the Name of the Property.
The value itself is not extracted there.
Ignore(d=> d.NullableString) == Ignore("NullableString").
The proposed solution @nwoolls removes the warning.
Perhaps the original idea using Ignore was something more?
vzalamea commentedon Jun 23, 2026
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?
DocSvartz commentedon Jun 24, 2026
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.
vzalamea commentedon Jun 24, 2026
the problem is when I have <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
vzalamea commentedon Jun 24, 2026
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.
DocSvartz commentedon Jun 24, 2026
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.
ramiabughazaleh commentedon Sep 4, 2026
Thank you, @DocSvartz .
It seems this made it into the v10.0.10 release.