Visual Studio 2022 keeps on deleting my code...

Marc Lisevich 46 Reputation points
2022-07-06T22:19:27.177+00:00

On Fresh Reinstall on Windows 11 with the latest Visual Studio. It loads up my project and bam!. All of the view models on my xamarin forms project have only a skeleton code and they are empty. I have tried touching all the files in the project to make sure they are new, deleting the .git config. Tried with multiple versions of the same project, creating a new project and also sometimes not all of the files are missing content only the two main ones that I am working on. Why is this happening? I will try code cleanup settings but what is there left to try? designer.cs files? Even when I import the code it is immediately gone?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,632 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Marc Lisevich 46 Reputation points
    2022-07-06T22:39:48.72+00:00

    So I discovered something. Visual Studio isn't even loading the code on the disk. I loaded the code, the deleted version shows up but I have a copy of the code in vs code and it hasn't been modified. So now the question becomes why is visual studio showing code that isn't even there? Is there a way to clean the cache?


  2. Marc Lisevich 46 Reputation points
    2022-07-07T08:37:08.99+00:00

    I found the solution. For some odd reason. the code shown is broken down and identified by different functions/classes. There is a drop down and I made a generic function GenerateIt(obj). If I select that in the drop down it makes all my code appear. It is the middle top right of Visual Studio. One of the options is generatedCode others are specific fragments of code.