Change to the way select and implicit casting works from v1.9.7 to v3.1.15
See original GitHub issueWe have a lot of code written against version 1.9.7 of the library which we are looking to upgrade to 3.1.15.
In our testing we have found an issue with code that looked like:
Option<int> someOption;
return
from val in someOption
select someList.FirstOrDefault(item => item.id == val);
Or in other places, the same type of code written in a similar way:
someOption.Map(val => someList.FirstOrDefault(item => item.id == val));
This code no longer works because now, if the expression in the select returns a null, it throws a null exception rather than the old behaviour of implicitly casting the null to a None.
Unfortunately v1.9.7 of the library is in a project with tens of thousands of lines of code and not enough unit tests, and since the code still builds the only way of finding the issues would be by eye or by attempting to test every use case of the system which is impractical.
Is this new behaviour how the library now works? Does the implicit cast of a null to a None work differently in 3.1.15 to 1.9.7? Or am I missing something?
Thanks Andy
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Or you can mark it with
[Obsolete("Review needed")]
and VS list of warning will give you all places.@andyigreg A couple of thoughts:
Map
could help?Map
toMapX
or something, and perhaps even comment out theSelect
extension method forOption
(and any other type that this might be a problem for). Then your code won’t compile in all the places where it’s used. This might be more of a curse than a blessing, but at least you’d know you audited everything.