Issue description
Looks like Option<string> in marked as NotNull when using NullabilityInfoContext. I expect it to be reported as Nullable since Option<string> for null has a null representation (UseNullAsTrueValue).
With provided snippet, I expect StringOption to be reported as Nullable, not NotNull.
StringOrNull = <null>
StringOption = None <-- this
ObjNull = <null>
ObjOrNull = <null>
StringOrNull => Nullable / Nullable
StringOption => NotNull / NotNull <-- this
ObjNull => Nullable / Nullable
ObjOrNull => Nullable / Nullable
Choose one or more from the following categories of impact
Operating System
macOS
What .NET runtime/SDK kind are you seeing the issue on
.NET SDK (.NET Core, .NET 5+)
.NET Runtime/SDK version
9.0.100-preview.6.24328.19
Reproducible code snippet and actual behavior
open System
open System
open System.Reflection
type MyClass(StringOrNull: string | null, StringOption: string option, ObjNull: objnull, ObjOrNull: obj | null) =
member val StringOrNull = StringOrNull
member val StringOption = StringOption
member val ObjNull = ObjNull
member val ObjOrNull = ObjOrNull
let classType = typeof<MyClass>
let ctor = classType.GetConstructors() |> Seq.exactlyOne
let paramInfos = ctor.GetParameters()
let inst = ctor.Invoke([| null; null; null; null |]) :?> MyClass
printfn "StringOrNull = %A" inst.StringOrNull
printfn "StringOption = %A" inst.StringOption
printfn "ObjNull = %A" inst.ObjNull
printfn "ObjOrNull = %A" inst.ObjOrNull
let nrtContext = NullabilityInfoContext()
for paramInfo in paramInfos do
let nrtInfo = nrtContext.Create(paramInfo)
let readState = nrtInfo.ReadState
let writeState = nrtInfo.WriteState
printfn $"{paramInfo.Name} => {readState} / {writeState}"
Possible workarounds
No response
Issue description
Looks like
Option<string>in marked as NotNull when usingNullabilityInfoContext. I expect it to be reported asNullablesinceOption<string>fornullhas anullrepresentation (UseNullAsTrueValue).With provided snippet, I expect
StringOptionto be reported asNullable, notNotNull.Choose one or more from the following categories of impact
nullconstructs in code not using the checknulls switch.null,not null).Operating System
macOS
What .NET runtime/SDK kind are you seeing the issue on
.NET SDK (.NET Core, .NET 5+)
.NET Runtime/SDK version
9.0.100-preview.6.24328.19
Reproducible code snippet and actual behavior
Possible workarounds
No response