dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.89k stars 784 forks source link

"Unused open statements" analyzer does not work on a very simple code #3775

Closed vasily-kirichenko closed 6 years ago

vasily-kirichenko commented 6 years ago

image

open System
open System.Threading

[<EntryPoint>]
let main _ =
    printfn "%A" System.DateTime.Now
    0
EBrown8534 commented 6 years ago

Shouldn't this emit that the name of System.DateTime.Now can be simplified instead?

vasily-kirichenko commented 6 years ago

no, that’s the work of a different analyzer.

vasily-kirichenko commented 6 years ago

this, and many other bugs, has been fixed in https://github.com/Microsoft/visualfsharp/pull/3803

EBrown8534 commented 6 years ago

@vasily-kirichenko I meant that this analyzer shouldn't run, and the other one should. I would think that if you open something, and call a method with the FQN including that opened thing, it would not emit this suggestion but instead allow the other analyzer to emit a "name can be simplified" suggestion.

vasily-kirichenko commented 6 years ago
  1. turn on the simplify name analyzer in the settings 2. build and install the vsix from my pr I mentioned. After that everything will work properly.
cartermp commented 6 years ago

@EBrown8534 The Simplify Name analyzer is off by default because it's expensive and bogs down the editor due to how document analyzers are run by Roslyn under the covers. You can see a breakdown of what happens in the editor here: https://github.com/dotnet/roslyn/issues/19347#issuecomment-310225540

EBrown8534 commented 6 years ago

@cartermp Ah, thanks! That clears things up for me.

cartermp commented 6 years ago

Fixed by #3803