Behavior with Nullable Interface while implicit maybe-generation
See original GitHub issueCurrently if facing in an issue / behavior with the implicit Maybe-generation. As for an example:
public interface ITest
{
}
private Maybe<ITest> CallMethod()
{
ITest? test = null;
return test;
}
The return test resulted in an error cannot convert expression ITest? to return type Maybe<ITest>.
Is there not an implicit conversion for nullable interfaces?
The above described problem is an easy example. In my code i receive (from Quartz.net) e.g. a Task<ITrigger?> and, also for async operations, the implicit conversion does not work.
Regards Laszlo
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
What is the reason why nullable reference types defined in ...
Nullability is indicated by attributes, which aren't part of the method signature. In this case, it's applied to the interface (add void ...
Read more >Nullable reference types
This article provides an overview of nullable reference types. You'll learn how the feature provides safety against null reference ...
Read more >Resolve nullable warnings
This set of warnings alerts you that you're dereferencing a variable whose null-state is maybe-null. These warnings are:.
Read more >Nullable differences in partial type base and interfaces #5107
Currently, the compiler doesn't have very coherent behavior when nullability differences are present across partial declarations.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi Vladimir, thanks for your response. I think you´re right. It is not the best idea to wrap an extension like maybe over a low level nullable handling like in c# 8.0 (which is exactly designed for). As i coded in Scala, there was the best practice to handle nulls as
None<T>or not nulls asSome<T>to avoid nulls from your code.I leave my function extensions to remove the nullables in my project. This is primarily syntactic sugar for me, to avoid the handling with
??and?.Thanks for your patience,
Regards, Laszlo
Sorry for late replies.
You can have it both ways:
or
The compiler will agree with either option.
Your suggestion is to add extensions for
T?, in addition toMaybe<T>? If so, I don’t think it’s a good idea, from the point of keeping the library focused on the one way of doing things.T?is an alternative toMaybe<T>. It makes sense to support the conversion from one to the other, but not re-implement the existing extension methods on top of both.