In Visual studio "Find usages" command does not find usages of public generic function, when one of its generic arguments is constrained by interface.
Steps to reproduce:
module Module
[<Interface>]
type IValueProvider =
abstract Value: int
let getValue (valueProvider: #IValueProvider) =
valueProvider.Value
let run () =
let valueProvider = {
new IValueProvider with
member _.Value = 0 }
getValue valueProvider
getValue.Expected behavior
One usage from function run should be found
Actual behavior
No references found to getValue
Known workarounds
Related information
I was trying to solve problem of managing dependencies in functional way using approach described in article Dealing with complex dependency injection in F#. It works great for me, except for described issue, which significantly complicated navigation across code-base.
Used versions:
This is seems to be related to a similar problem I experienced with VS 16.7 for several functions in our codebase.
Here is a minimal repro: Paste the following contents into a new .NET Core F# class library's Library.fs:
module Mod
let gen (_: 'a) = ()
gen true
"Find all references" on the generic function gen does not show the usage in the line below, making gen private works.
Ugh, definitely an annoying bug here. Note that in an F# script file, both repros succeed and show the reference.
Fixed by https://github.com/dotnet/fsharp/pull/9934#event-3654561306