Unity Crash and recovering from scene corruption

Hi,
I’ve just had a series of unity disasters and I’m hoping some more seasoned Unity developers can help me out.
Yesterday, Unity crashed and appeared to corrupt my project in interesting ways that I’m now trying to unpick.
I’ve since been through a bit of a mill of trying the latest version (2019.3.0a6, was on 2019.1 I think) but I think that’s just caused more problems.
Firstly, I’m having trouble connecting to visual studio. Unity seems to be having problems building project files, spamming the following message:

ArgumentException: Value does not fall within the expected range.
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit) (at :0)
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits () (at :0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder…ctor () (at :0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase () (at :0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject () (at :0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles () (at :0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <23c160f925be47d7a4fd083a3a62c920>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[ ] parameters) (at <23c160f925be47d7a4fd083a3a62c920>:0)
VisualStudioEditor.ProjectGeneration.OnPreGeneratingCSProjectFiles () (at Packages/com.unity.ide.visualstudio/Editor/ProjectGeneration.cs:423)
VisualStudioEditor.ProjectGeneration.Sync () (at Packages/com.unity.ide.visualstudio/Editor/ProjectGeneration.cs:173)
VisualStudioEditor.VSEditor.SyncAll () (at Packages/com.unity.ide.visualstudio/Editor/VSEditor.cs:160)
UnityEditor.CodeEditorProjectSync.SyncAndOpenSolution () (at C:/buildslave/unity/build/Editor/Mono/CodeEditor/CodeEditorProjectSync.cs:43)

Now, looking at that, I’m assuming that there’s something in my project that’s causing this to barf but I can’t figure out from this message what this is and, not having the source to unity, I cannot debug this. I’ve seen others with this problem in previous unity version but none of the fixes have worked for me.

I should add that this problem doesn’t seem to affect new scenes, just my existing scene. I can debug new scenes fine without this message appearing. Therefore, I expect that there’s something amiss in either my .unity file or in other unity assets.

I thought ‘a901e57d882e417bb0759af906b6d012’ looked like a GUID (as a side note, is there a way of replacing those with dot delimited DOM identifiers, such as ‘myscene.myobject::mycomponent’ or something, like you might have writing html/javascript? it’s hard to debug a GUID) but I couldn’t find any references to that in my scene.

Is there somewhere I should look in my ‘.unity’ files, some value that’s ‘out of range’ that I might place ‘back in range’. It’s not a lot to go on but perhaps somebody who is familiar with this code can throw me a bone.

Secondly, in upgrading to the latest version of unity, there seem to be some obsoleted API calls in the library I’m maintaining- nothing too onerous (GUIxxx replaced by ui.xxx, that sort of thing) but the problem is, this seems to have caused values in instances of components to fail and then lose their values. At some point, probably while tearing my hair out with other unrelated problems, the unity file has been saved and corrupted my scene (or perhaps this happened during the crash, hard to say). Is this a common problem in Unity?

I still don’t know what caused scripted components to lose their values. This was very inconvenient but I managed to restore most of them using a python script to merge values from an earlier unity file to the corrupted newer one. A more recent backup was also corrupted by the editor.

Regarding the ‘Value does not fall within the expected range’ error, I’m not sure how to proceed. This is affecting the functionality of Unity and Visual studio (cannot open visual studio via ‘Open c# project’, intellisense appears to be disabled for unity objects within visual studio, cannot connect visual studio to unity) but I have no way of knowing what is causing this problem in the project -the error messages give no context such as 'unity failed whilst processing a file called ‘xxxx’ that would help me trouble shoot the issue.

What would really help is if the process unity uses to prepare the visual studio files was more forgiving and more informative.

Any advice would be welcome.

About the crash:

If you are using an alpha version of the engine, it’s going to crash. It crash with final versions so how the hell is it not going to crash in an alpha. I recommend you to ALWAYS use a repository, no exceptions, unless you are voluntarily doing something to make it crash or just unimportant tinkering with new packages/versions whatever. The simplest repository solution (free of charge) I have found is BitBucket + GitKraken, so there’s that.

Also values not appearing in the scene means the crash/corruption occurred during the scene saving, which have happened to me once when changing the project version (2018.1.1 to 2018.1.3) the first time I save the scene after changing something in it. I think It have to do with updated basic components which for some reason don’t merge well with older versions of itself, but ultimately I have no idea what I’m talking, so I just use a repo and pray.

About Visual Studio:

For some reason, sometimes the files that VS looks into when opening the project get corrupted and it start opening scripts individually. The simples solution I have found is to clean the project and let Unity rebuild everything. This is done by deleting everything but the Assets and Project Settings folder. I know the error should be in the .snl file but sometimes deleting this unique file isn’t enough for some reason, so when I have this problem I usually do a full reset.
(Also if you are using VSCommunity, make sure to have the “Tools for Unity” up to date)

You clearly look experienced so probably you already knew all of this but ¯_(ツ)_/¯
Good luck with your project c: