Skip to content

fix: dead-reference projects no longer blank the list; flag missing projects#3

Open
nielsr2 wants to merge 1 commit into
maoyeedy:masterfrom
nielsr2:fix/dead-ref-projects
Open

fix: dead-reference projects no longer blank the list; flag missing projects#3
nielsr2 wants to merge 1 commit into
maoyeedy:masterfrom
nielsr2:fix/dead-ref-projects

Conversation

@nielsr2

@nielsr2 nielsr2 commented Jul 17, 2026

Copy link
Copy Markdown

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 entire foreach over projects in a single try/catch that silently swallows exceptions:

foreach (var property in data.EnumerateObject())   // all inside one try
{
    Title        = projectInfo.GetProperty("title")...       // throws if missing
    Version      = projectInfo.GetProperty("version")...     // throws if missing
    LastModified = projectInfo.GetProperty("lastModified").GetInt64()  // throws if missing / not a number
}

GetProperty(...) throws when a field is absent. So a single malformed/incomplete entry aborts the whole loop, the catch eats 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() the if (GroupFavoritesFirst) block had no else, so with that setting turned off the list rendered empty regardless of dead refs.

Changes

  • ProjectParser — parse each entry independently (per-entry try/catch); use TryGetProperty + fallbacks instead of throwing GetProperty; guard lastModified value kind. One bad entry is now skipped, never fatal. Split out a pure ParseProjects(string) so the logic is testable/runnable without the SDK. Now also records whether the project folder still exists on disk.
  • UnityExtensionPage — fixed the missing else so 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 on Directory.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 an Exists flag 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:

  • Green Debug build — dotnet build -c Debug -p:Platform=x64 → 0 warnings, 0 errors (analyzers on).
  • Ran the new ParseProjects against a real projects-v1.json with 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.
  • csharpier clean.

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant