Skip to content

[Tooling] "Find usages" command does not work for public generic function with constraint by interface #9863

@GennadyGS

Description

@GennadyGS

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:

  1. Open Visual Studio 2019
  2. Use menu New -> Project -> Class Library (.NET Core, F#)
  3. Replace content of generated file Library.fs with following code:
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
  1. Invoke command "Find usages" from context menu for function getValue.

Expected behavior

One usage from function run should be found

Actual behavior

No references found to getValue

Known workarounds

  1. Find usages manually, which is extremely inconvenient.
  2. Make target function private. Requires merging multiple modules in one, which is not acceptable in my case.

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:

  • Windows 10.0.17763 Build 17763
  • .NET Core 3.1.6
  • Visual Studio 16.6.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions