Closed Bykiev closed 5 months ago
I found the test ExpressionThrowsNullReferenceExceptionWithoutNullOption
, which checks for NRE, so, it's not a bug. Should we throw ArgumentNullException
then? It'll be a breaking change.
The change you're suggesting sounds reasonable. I don't even think it needs a minor version change.
Thanks, I've reopened the PR and fixed the test case to handle ArgumentNullException
. Please, review it
I found a bug, which should be discussed: when expression contains null parameter and null parameters are not allowed a
NullReferenceException
is thrown. We don't need to get the most precise type if any of parameters is nullhttps://github.com/sklose/NCalc2/blob/4e0338cbf84236087b793430aa91287270a1df05/src/NCalc/Domain/EvaluationVisitor.cs#L68-L81
If the null parameters are not allowed we should throw
ArgumentNullException
instead, but it'll lead to breaking change. I think the best choice will be check first if any of parameters is null and don't throw any exceptions likeEvaluateOptions.AllowNullParameter
is specified. What do you think?Upd: since if one or both null parameters in expression will cause
NullReferenceException
it will not be a breaking change and it's safe to throwArgumentNullException
, but a minor version increase should be done