question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change to the way select and implicit casting works from v1.9.7 to v3.1.15

See original GitHub issue

We 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
StanJavcommented, Apr 16, 2019

One brutal way would be to do your own build on lang-ext where you rename Map to MapX

Or you can mark it with [Obsolete("Review needed")] and VS list of warning will give you all places.

0reactions
louthycommented, Apr 16, 2019

@andyigreg A couple of thoughts:

  • In VS, find all references on Map could help?
  • One brutal way would be to do your own build on lang-ext where you rename Map to MapX or something, and perhaps even comment out the Select extension method for Option (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.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Implicit conversion in SQL Server
This article will provide an overview of SQL Server implicit conversion including data type precedence and conversion tables.
Read more >
c# - Implicit conversion without assignment?
While it's true that an implicit cast won't work here, you could possibly do better than an explicit cast by adding a Value...
Read more >
Casting and type conversions - C# Programming Guide
Learn about casting and type conversions, such as implicit, explicit (casts), and user-defined conversions.
Read more >
Dataproc release notes
These release notes apply to the core Dataproc service, and include: Announcements of the latest Dataproc image versions installed on the Compute Engine...
Read more >
MPLAB XC16 C Compiler User's Guide
No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights unless otherwise stated. Note the following details of the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found