dotnet / dotnet/fsharp

C# extensions show up in VS auto-complete as overloads on unrelated types

Open
#14,636 0 comments 0 reactions 0 assignees View on GitHub
Area-LangService-AutoComplete Bug Impact-Medium
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

Extensions defined on typed arrays (e.g. `int[]`) in a C# library show up in VS auto-complete on unrelated types in F# code. This seems to happen if the type has a method with the same name as the extension.

**Repro steps**

[ConsoleApp1.zip](https://github.com/dotnet/fsharp/files/10467393/ConsoleApp1.zip)

```csharp
namespace ClassLibrary1
{
public static class ArrayExtensions
{
public static void DoSomething(this int[] array, bool thisIsAnExtension)
{ }
}
}
```
```fsharp
open ClassLibrary1

type Foo() =
// Method with the same name as the array extension.
member x.DoSomething(value : int) = ()

// Works as intended
let array = [| 0; 1; 2 |]
array.DoSomething(true)

// Does not compile as intended, but shows up in auto-complete
let foo = Foo()
foo.DoSomething(false)
```

**Expected behavior**

The extension should not show up in auto-complete as an overload.

**Actual behavior**

The extension shows up in auto-complete.

![ext](https://user-images.githubusercontent.com/39337420/213730867-f529c654-93ad-4516-bd44-35768ff78c5c.png)

The compiler error also lists the extension as possible overload:

![overloads](https://user-images.githubusercontent.com/39337420/213732066-17e3cf4e-e24d-434f-9d42-92255187f91e.png)

**Related information**

* Windows 10
* .NET 7
* Visual Studio 17.4.4

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.