dotnet / dotnet/fsharp

Adding an FSI Signature File removes generic type resolution in tooltips

Open
#14,124 4 comments 1 reaction 1 assignee Claimed by @T-Gro View on GitHub
Area-LangService-ToolTips Bug Impact-Medium Theme-Simple-F#
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

If you create a `*.fsi` file and it contains functions with generic types, then those types will no longer be resolved in tooltips, greatly hampering one of the key tools for F# development: type discovery.

Possibly related is this fix: https://github.com/dotnet/fsharp/issues/11022

### Repro steps

1. Create a new project with a `test.fs` file in it, like this and then observe tooltip behavior of `makeString`:

```f#
namespace HelloWorld.Tests

module FsiTest =
let makeString x = string x
let f() = makeString 42
```

2. Add an extra source file and call it `test.fsi`, have it contain this and again observe tooltip behavior of `makeString` in the file above:

```
namespace HelloWorld.Tests

module FsiTest =
val makeString: x: 'T -> string
```

## Expected behavior

In the first case, the tooltip looks like this, i.e., showing the resolution of the generic types, in this case `'a is int`:

![image](https://user-images.githubusercontent.com/16015770/196067031-7d7ab0f3-2cd7-4b7a-994d-9b4092721141.png)

In the second case, the tooltip should look like this (the same, except for `'a is int` now being `'T is int`):

![image](https://user-images.githubusercontent.com/16015770/196067078-ec2032ff-dabc-4b83-b127-4cb00d962a76.png)

## Actual behavior

Instead, the type information for the generics resolution completely disappears:

![image](https://user-images.githubusercontent.com/16015770/196067215-01903a30-432f-41e8-90d7-dd8fee20bde7.png)

## Known workarounds

I know of only two:

* Do not use `*.fsi` files, not really an option, though, in public libraries or when you want to restrict the surface area.
* While working, set compile action to `None`, which gives back the tooltips, then reset it to `F# compiler` before you compile.

Neither is particularly appealing, so if there's something I'm missing, I'd love to hear it!

## Related information

* Seen in VS 2022 GA release and VS 2022 Preview
* Seen with simple and more complex type signatures
* Renaming `'T` to `'a` as in the signature file does not help
* Explicitly using the same generic type in the implementation file, i.e. `makeString (x: 'T) = string x` doesn't help either
* Also happens if this project is referenced by another project. That other project suffers the same issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.