fix: dead-reference projects no longer blank the list; flag missing projects#3
Open
nielsr2 wants to merge 1 commit into
Open
fix: dead-reference projects no longer blank the list; flag missing projects#3nielsr2 wants to merge 1 commit into
nielsr2 wants to merge 1 commit into
Conversation
…ects Parse each Unity Hub project entry independently so one malformed or incomplete entry (e.g. a moved/deleted "dead reference") can no longer abort parsing and blank the whole list. Also fixes GetItems rendering nothing when "Group favorites first" is disabled (previously a missing else branch). Projects whose folder no longer exists on disk are now flagged with a warning icon and a "Missing" tag, are non-launching (toast instead of starting Unity), and can be hidden via a new "Hide projects missing from disk" setting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On some machines the extension shows no projects at all. The trigger is stale/dead references in Unity Hub's
projects-v1.json— entries for projects that have been moved or deleted from disk. Removing those entries by hand makes the list reappear, which points straight at the parser.Root cause
ProjectParser.GetUnityProjects()wrapped the entireforeachover projects in a singletry/catchthat silently swallows exceptions:GetProperty(...)throws when a field is absent. So a single malformed/incomplete entry aborts the whole loop, thecatcheats it, and the method returns only the projects parsed before the bad one — often zero. That's the empty list.A second, latent bug: in
UnityExtensionPage.GetItems()theif (GroupFavoritesFirst)block had noelse, so with that setting turned off the list rendered empty regardless of dead refs.Changes
ProjectParser— parse each entry independently (per-entrytry/catch); useTryGetProperty+ fallbacks instead of throwingGetProperty; guardlastModifiedvalue kind. One bad entry is now skipped, never fatal. Split out a pureParseProjects(string)so the logic is testable/runnable without the SDK. Now also records whether the project folder still exists on disk.UnityExtensionPage— fixed the missingelseso projects always render (favorites-first and flat paths now share one code path); missing-on-disk projects get a warning icon, a red "Missing" tag, and a "(folder not found)" subtitle.OpenUnityCommand— guards onDirectory.Exists; a dead reference shows a toast instead of launching Unity against a missing path (also race-safe if a folder is deleted after the list is built).SettingsManager— new toggle "Hide projects missing from disk" (default: off / shown).UnityProject/Resources— added anExistsflag and the warning glyph.Behaviour
Dead references are no longer able to blank the list. By default they're shown, clearly flagged, and non-launching; users who prefer a clean list can hide them with the new setting.
Verification
This repo has no unit-test project, so verification was:
Debugbuild —dotnet build -c Debug -p:Platform=x64→ 0 warnings, 0 errors (analyzers on).ParseProjectsagainst a realprojects-v1.jsonwith 24 projects, 15 of them dead references: all 24 parse, the 15 missing folders are correctly flagged, favorites are detected, and the previously-empty list is fully populated.csharpierclean.🤖 Generated with Claude Code