Here is the half-done maybe CE
Repro steps
Here is the half-done maybe CE, extension for it that adds Bind-overload and usage attempt:
namespace Case1
module MaybeBuilder =
type MaybeBuilder() =
member inline _.Bind(optionValue: 'T option, f) =
match optionValue with
| None -> None
| Some value -> f value
member inline _.Return maybeNull =
if isNull maybeNull then None else Some maybeNull
member inline _.Delay f = f
member inline _.Run f = f()
let maybe = MaybeBuilder()
module MaybeBuilderExtension =
open MaybeBuilder
type MaybeBuilder with
member inline _.Bind(maybeNull: 'T, f) =
if isNull maybeNull then None else f maybeNull
module Usage =
open MaybeBuilder
open MaybeBuilderExtension // TODO: false positive
let foo (s: string) =
maybe {
let! a = s
return a
}
Visual Studio marks open MaybeBuilderExtension as safe to remove.

However it would break compilation of code because we actually use Bind from extension.
Expected behavior
open for builder extension isn't marked as unnecessary.
Actual behavior
It's marked as unnecessary.
Known workarounds
.
Related information
.NET SDK: 7.0.403
Visual Studio 17.7.6
Here is the half-done
maybeCERepro steps
Here is the half-done
maybeCE, extension for it that adds Bind-overload and usage attempt:Visual Studio marks

open MaybeBuilderExtensionas safe to remove.However it would break compilation of code because we actually use
Bindfrom extension.Expected behavior
openfor builder extension isn't marked as unnecessary.Actual behavior
It's marked as unnecessary.
Known workarounds
.
Related information
.NET SDK: 7.0.403
Visual Studio 17.7.6