-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Code CleanUp - Remove unnecessary Using - removes usings from files not in loaded projects/solution #60867
Comments
The issue seems to be that VS is configured as the git mergetool and the user is resolving conflicts in C#/VB.NET files that are not part of a loaded Project. The CodeCleanup routine fires when this file is saved and Roslyn is applying fixes to this loose document. Proposed fix: In CodeCleanup, check that the document is part of a loaded Project (not miscellaneous workspace) before applying fixes. |
Unfortunately, this is not the case with me. I have opened a solution/multiple project files. |
@FelixDamrau, I saw the same with TFS-Merge. (My VS is configurated to use Visual Studio Team Fundation Server as Sourcecontrol) Remark: |
That sounds plausible. |
+1, this issue is very annoying. As someone who uses code cleanup a lot, in order to keep my code tidy, its very frustrating when I forget about this bug and merge... VS does not have an option to import all missing usings, and for big files that usually have a lot of imports its a very big pain to add them back. Please prioritise fixing this. |
@RapGeneral this is on the backlog. But if it's something you are passionate about, we would likely take a community pr here if you wanted to contribute it. |
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work] [regression] [worked-in:17.1 Preview 1]
Hi,
In the Code Cleanup 'Remove unnecessary usings' removes needed imports(VB.Net) when doing a TFS-Diff of a File not in any loaded projects.
So if I use a new VS instance to check the changes from a merge, and have the new option 'Code Cleanup on Save' activated, then the Code CleanUp gets executed after resolving Conflicts, and sometimes removes needed Imports (VB.Net, keyword using in C#).
In Version '17.1 Preview 1' and earlier I used a extention to call 'Code Cleanup on Save' and this didn't happen at that time, it only started happening after installing '17.1 Preview 2' and activating the integrated 'Code Cleanup on Save'-Feature
Original Comments
Feedback Bot on 1/20/2022, 10:32 PM:
(private comment, text removed)
Feedback Bot on 1/21/2022, 09:48 AM:
(private comment, text removed)
Alexander Wurzinger on 3/10/2022, 02:46 AM:
(private comment, text removed)
Jose Mira on 3/11/2022, 08:27 AM:
(private comment, text removed)
Alexander Wurzinger on 3/11/2022, 09:49 AM:
(private comment, text removed)
Coffee on 3/27/2022, 11:02 PM:
(private comment, text removed)
Coffee on 4/11/2022, 05:45 AM:
(private comment, text removed)
Jorge Durán on 4/12/2022, 00:42 AM:
(private comment, text removed)
Coffee on 4/13/2022, 01:28 AM:
(private comment, text removed)
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: