I propose we improve interop to C#-defined Nullable-typed optional parameters
Consider a C# definition
public int SomeMethod(int? channels = 0, int? ratio = 1)
The compiled form of this uses Nullable typed values for the parameters with default value nullref.
We do not recognise this in F# and when calling and providing a value we require
C.SomeMethod(channels = Nullable 3)
C.SomeMethod(channels = Nullable 3, ratio = Nullable 3)
C.SomeMethod(ratio = Nullable 3)
Alternatives that achieve the same effect are
-
to allow auto-conversion from T to Nullable<T> at method calls. Indeed this is probably the best solution.
-
some even more aggressive auto-conversion rule for T to Nullable<T>
Pros and Cons
The advantages of making this adjustment to F# are interop with modern C# becomes smoother.
The disadvantages of making this adjustment to F# are
- another implicit conversion rule is added.
- we have to be careful this is not a breaking change
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
I propose we improve interop to C#-defined
Nullable-typed optional parametersConsider a C# definition
The compiled form of this uses
Nullabletyped values for the parameters with default valuenullref.We do not recognise this in F# and when calling and providing a value we require
Alternatives that achieve the same effect are
to allow auto-conversion from
TtoNullable<T>at method calls. Indeed this is probably the best solution.some even more aggressive auto-conversion rule for
TtoNullable<T>Pros and Cons
The advantages of making this adjustment to F# are interop with modern C# becomes smoother.
The disadvantages of making this adjustment to F# are
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply: