After accepting the merge with Visual Studio 2022 (pro), using statements got deleted. what could be the issue here?

Gourik Kumar Bora 20 Reputation points
2023-03-14T07:26:03.3333333+00:00

After accepting the merge with Visual Studio 2022 (pro), using statements got deleted.

Developer technologies | Visual Studio | Other
{count} votes

3 answers

Sort by: Most helpful
  1. Zitong Yang 10 Reputation points Microsoft Employee
    2023-08-31T03:38:32.3933333+00:00

    It is definitely related to the code cleanup feature in Visual Studio. After I remove the "Remove unnecessary imports or usings" fixer from my code cleanup profile, the problem is gone. However, I don't want to do that because this fixer is useful in other scenarios. It seems that the code cleanup tool identifies those using statements as unused by mistake after accepting the merge result.

    1 person found this answer helpful.
    0 comments No comments

  2. Phil Stratford 0 Reputation points
    2023-06-13T09:19:17.4466667+00:00

    Yep, I'm seeing this too. Pretty disastrous, really. I do a merge from Branch A to Branch B and using statements from dozens of files are removed, meaning that the app suddenly won't compile. Seems to leave me with two non-options: Don't do the merge, or manually re-add the usingstatements to every file.

    0 comments No comments

  3. Phil Stratford 0 Reputation points
    2023-10-21T21:12:23.2333333+00:00

    Glad it's not just me. This is a horrendous bug/issue. Turned off Code Cleanup for now, based on the answer from @Zitong Yang . I don't know if complaining about it here is going to help - are the Visual Studio devs aware of this issue?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.