From 90f90b3d0e59114300c9792682cd9ca60acdcfdf Mon Sep 17 00:00:00 2001 From: Theorist100 <111704408+Theorist100@users.noreply.github.com> Date: Fri, 17 Jul 2026 18:55:27 +0300 Subject: [PATCH] Tests: skip incomplete Unity installations when probing for an editor On Windows, uninstall leftovers and stripped editors can remain under the Unity Hub folder with only a Resources subfolder. They register as valid installations and sort first, so FirstInstallation() returns a folder without managed assemblies and every test fails with missing references. Only register an installation if UnityEditor.dll is present, checking both the classic layout and the macOS 6000.3+ Resources/Scripting layout. --- src/Microsoft.Unity.Analyzers.Tests/UnityPath.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Unity.Analyzers.Tests/UnityPath.cs b/src/Microsoft.Unity.Analyzers.Tests/UnityPath.cs index 1a352e78..5a277ad9 100644 --- a/src/Microsoft.Unity.Analyzers.Tests/UnityPath.cs +++ b/src/Microsoft.Unity.Analyzers.Tests/UnityPath.cs @@ -117,7 +117,14 @@ private static void RegisterRegistryInstallations() private static void RegisterUnityInstallation(string path) { - if (!string.IsNullOrEmpty(path) && Directory.Exists(path)) + if (!string.IsNullOrEmpty(path) && Directory.Exists(path) && HasManagedAssemblies(path)) _unityInstallations.Add(path); } + + private static bool HasManagedAssemblies(string path) + { + // Skip partial installations (uninstall leftovers, stripped editors) + return File.Exists(Path.Combine(path, "Managed", "UnityEditor.dll")) + || File.Exists(Path.Combine(path, "Resources", "Scripting", "Managed", "UnityEditor.dll")); + } }