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

Tooling-added opens are placed above top-level #-directives in scripts when top-level insertions are set #8514

Open
Tracked by #15408
cartermp opened this issue Feb 8, 2020 · 4 comments
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Feature Improvement Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@cartermp
Copy link
Contributor

cartermp commented Feb 8, 2020

See the following:

image

Since the setting for inserting suggested open statements is set to top-level, it places it at the top of the file.

However, it could be argued that #r/#load-directives are special, and "top-level" open statements should go below them.

Note that if top-level is not set in settings, then it will place open statements below these declarations. However, this will also place opens within the nearest scope.

@kevmal
Copy link
Contributor

kevmal commented Feb 9, 2020

Perhaps it's a separate issue but I consider it a bug since the "fix" introduces an error, namely, opening a namespace before the assembly is referenced. Meanwhile visual studio sees no error even though it'll fail once sent to FSI.

This looks all good:
image

This is what happens when sent to FSI:

Script7.fsx(1,17): error FS0039: The namespace 'Linq' is not defined.

@cartermp cartermp modified the milestones: Unknown / not bug, Backlog Feb 9, 2020
@cartermp
Copy link
Contributor Author

cartermp commented Feb 9, 2020

Thanks for the example, labeling as a bug

@cartermp cartermp changed the title Consider placing opens below top-level #-directives in scripts when top-level insertions are set opens are placed above top-level #-directives in scripts when top-level insertions are set Feb 9, 2020
@cartermp cartermp changed the title opens are placed above top-level #-directives in scripts when top-level insertions are set Tooling-added opens are placed above top-level #-directives in scripts when top-level insertions are set Feb 9, 2020
@dsyme dsyme added the Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. label Aug 31, 2020
@cartermp cartermp added Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. and removed Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. labels Sep 1, 2020
@cartermp
Copy link
Contributor Author

cartermp commented Sep 1, 2020

@dsyme I've bumped this up from low severity. With package references in scripts we're likely to see a lot more scripting since it'll be so much easier to just reference stuff and go to town on it. If it weren't for package references I'd say low severity is fine

@psfinaki
Copy link
Member

Okay I created a separate issue for the FSI thing since, as of now, the behavior is inconsistent regardless of the order of the open and #r lines.

This one holds for the original problem but feels more as an improvement, since at least VS can compile the "fixed" version.

@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 Feature Improvement Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
Status: New
Development

No branches or pull requests

4 participants