Issue description
Consider this code as a placeholder for a type defined in an external library:
[<AllowNullLiteral>]
type IInterfaceFromExternalPackage = interface end
[<AllowNullLiteral>]
type ImplementorFromExternalPackage() =
interface IInterfaceFromExternalPackage
Now consider the following:
open Microsoft.Extensions.DependencyInjection
ServiceCollection().AddSingleton<IInterfaceFromExternalPackage>(ImplementorFromExternalPackage())
This causes a compiler warning:
FS3261 : Nullness warning: The type 'IInterfaceFromExternalPackage' supports 'null' but a non-null type is expected.
Of course, there is no actual nullness issue here since I pass a non-null (singleton) instance of the type. However, I can find no way of silencing this warning apart from disabling it entirely for the file.
Choose one or more from the following categories of impact
Operating System
Windows (Default)
What .NET runtime/SDK kind are you seeing the issue on
.NET SDK (.NET Core, .NET 5+)
.NET Runtime/SDK version
.NET SDK 9.0.100
Reproducible code snippet and actual behavior
No response
Possible workarounds
No response
Issue description
Consider this code as a placeholder for a type defined in an external library:
Now consider the following:
This causes a compiler warning:
Of course, there is no actual nullness issue here since I pass a non-null (singleton) instance of the type. However, I can find no way of silencing this warning apart from disabling it entirely for the file.
Choose one or more from the following categories of impact
nullconstructs in code not using the checknulls switch.null,not null).Operating System
Windows (Default)
What .NET runtime/SDK kind are you seeing the issue on
.NET SDK (.NET Core, .NET 5+)
.NET Runtime/SDK version
.NET SDK 9.0.100
Reproducible code snippet and actual behavior
No response
Possible workarounds
No response