Unity and Visual Studio solution problem

Since a sync issue with One Drive something has broken between Unity and Visual Studio.

In Unity the recently edited c# scripts appear as generic files. When you click on them, a preview of the contents are not displayed in the inspector and they will not automatically open in VS when double clicked.
The Game Objects these scripts are attached to just state they are missing and the error states:
The associated script can not be loaded.
Please fix any compile errors and assign a valid script.

Any working scripts that reference any of these scripts throw errors: The type or namespace name could not be found (are you missing a using directive or an assembly reference.

However, the scripts are fine, from the explorer will open normally in Visual Studio and have no errors.

From within the Visual Studio Solution the scripts that were open are still there and seem fine, however, if you make changes and attempt to save you are met with the following message from CodeMaid:

.cs is not in the solution so some cleanup actions may be unavailable.

Clearly some file has become corrupt. I’ve tried to restore the old .sln and vs files and folders, but the problem persists. Is there anything else I could try replacing. I would prefer not to have to resort to restoring everything from backup and losing work… especially as everything was working and still seems intact!

Any thoughts?

TIA

It should be safe to delete the .sln and .vs files, Unity regenerates them from scratch every time you recompile. It might be that you have other corrupt files, so a nuclear opinion would be to delete those as well as the library folder, and then reopen the project in Unity. That’ll cause all the files to reimport, and should clean up corrupt things.

If that doesn’t fix things in Unity, you probably have some actual code errors somewhere. If Visual Studio is still broken that’s just par for the course for VS.

Fantastic! Thank you very much for the quick reply Baste.
I’ll give that a go when I’m next at my desk.