dotnet / dotnet/fsharp

False positive IDE0005 "Open declaration can be removed" when opening namespaces from some nuget packages

Open
#12,667 1 comment 0 reactions 0 assignees View on GitHub
Area-LangService-UnusedOpens Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Repro solution: [Repro.zip](https://github.com/dotnet/fsharp/files/7956933/Repro.zip)

For some NuGet packages, VS (and Rider) says that there are unused opens:

![image](https://user-images.githubusercontent.com/7766733/151511905-6dad0260-83a5-4cf7-bae2-4c9a2ea458ce.png)

If I remove any of these, compilation fails. If I reorder them, the topmost one is always OK and the other ones are marked as unused. (In more complex projects, I have seen correctly-marked-as-used opens between incorrectly-marked-as-unused opens.)

The repro contains the actual nupkg files for a few packages from our internal company feed. The repro project is configured via `nuget.config` to use these, and will automatically restore from these, using a local `packages` folder for good measure. There is AFAIK nothing non-standard in the way these are created. However, when trying to reduce the repro further, even the next small step - copying the relevant projects as-is into the solution and using the nupkg files that are generated by that build - causes the bug to go away.

Please let me know if you need the source of the packages. (They are, strictly speaking, internal company projects, but should be safe enough to publish here.)

The bug reproduces in the latest VS as well as Rider. I therefore suspect this has to do with some F# component, e.g. FCS. (I don't really know much about that ecosystem, so apologies if I'm using incorrect terms.)

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.