Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous 'open' statement simplification #4046

Closed
Tracked by #15408
saul opened this issue Dec 1, 2017 · 11 comments
Closed
Tracked by #15408

Erroneous 'open' statement simplification #4046

saul opened this issue Dec 1, 2017 · 11 comments
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics

Comments

@saul
Copy link
Contributor

saul commented Dec 1, 2017

I have the following code in an F# file that uses SQL:

open System
open System.Data // "System." is marked as unnecessary
open System.Data.SqlClient // "System.Data." is marked as unnecessary

Expected behavior

Open statements should should never be simplified.

Actual behavior

Namespace is simplified, resulting in:

FS0893: This declaration opens the namespace or module 'System.Data.SqlClient' through a partially qualified path. Adjust the code to use the full path of the namespace. This change will make your code more robust as new constructs are added to the F# and CLI libraries.

Known workarounds

Ignore the simplification

@saul
Copy link
Contributor Author

saul commented Dec 1, 2017

Whoever gets around to looking at this - it's worth pointing out that there is a very similar bug with namespace statements:

namespace Foo.Bar

open Foo

then the Foo in the namespace statement is marked as being unnecessary - the code fixer tries to simplify the namespace statement!

@vasily-kirichenko
Copy link
Contributor

Unacceptable. Just unacceptable :)

@TIHan
Copy link
Member

TIHan commented Dec 5, 2017

@saul could you provide a full sample or sample project?

@cartermp
Copy link
Contributor

cartermp commented Dec 5, 2017

@saul with the following class library project I don't see what you're reporting:

namespace Testy

open System
open System.Data
open System.Data.SqlClient

module Foo =
    let f() =
        use conn = new SqlConnection()
        ()

System and System.Data are greyed out, but I would expect that. No option to simplify names (if I turn on the feature).

testy

@saul
Copy link
Contributor Author

saul commented Dec 5, 2017

Of course because they aren’t being used... try using something from System and System.Data.

@cartermp
Copy link
Contributor

cartermp commented Dec 5, 2017

Works for me:

works

If I fully qualify, then I get the suggestion to remove the unused namespace, but that's it. No option to simplify a namespace.

@vasily-kirichenko
Copy link
Contributor

@cartermp have you turned on the feature?

@cartermp
Copy link
Contributor

cartermp commented Dec 6, 2017

@vasily-kirichenko
Copy link
Contributor

I can reproduce it on 15.5 preview 5

image

@vasily-kirichenko
Copy link
Contributor

Fixed in #4068

@TIHan
Copy link
Member

TIHan commented Dec 6, 2017

I was able to reproduce. When you turn on the feature, it doesn't immediately reflect. You have to close the window and re-open.

@TIHan TIHan closed this as completed Dec 6, 2017
@psfinaki psfinaki added the Area-LangService-CodeFixes Code fixes associated with diagnostics label Jun 15, 2023
@psfinaki psfinaki mentioned this issue Jun 15, 2023
85 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics
Projects
None yet
Development

No branches or pull requests

5 participants