Skip to content

Speed up custom-tool migration detection using compile errors instead of always scanning#1954

Merged
hatayama merged 3 commits into
feature/migration-error-driven-autoscan-integrationfrom
feature/migration-flag-lifecycle-and-startup-wiring
Jul 22, 2026
Merged

Speed up custom-tool migration detection using compile errors instead of always scanning#1954
hatayama merged 3 commits into
feature/migration-error-driven-autoscan-integrationfrom
feature/migration-flag-lifecycle-and-startup-wiring

Conversation

@hatayama

@hatayama hatayama commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • The custom-tool migration wizard now opens only when a compile error actually indicates leftover V2 legacy API usage, instead of always opening and scanning the whole project after a V2→V3 upgrade.
  • When it does open via auto-detection, the migration scan is scoped to the assemblies affected by the matched compile errors instead of scanning all of Assets/.

User Impact

  • Before: after upgrading to V3, the migration wizard always popped up and ran a full-project scan, even when the project had no legacy custom-tool code, and the scan could take a while to start.
  • After: the wizard only appears when Unity's own compiler has already flagged legacy V2 API usage, mirroring how Unity's built-in API Updater detects upgrade-affected code. When it appears, the initial scan only looks at the affected assemblies, so it starts and finishes faster.

Changes

  • Added console-error-to-legacy-API matching (ThirdPartyToolMigrationConsoleErrorParser) and a lightweight assembly walker to scope the migration scan to only the assemblies touched by matched errors.
  • SetupWizardStartupFlow now gates the auto-scan window on EditorUtility.scriptCompilationFailed plus a compile-error-log match, instead of unconditionally opening on a version-gate check alone.
  • The manual Window/Unity CLI Loop/Custom Tool Migration entry point is unchanged and still performs a full-project scan.
  • Reverted an in-flight flag-lifecycle change (deferring auto-scan flag consumption until scan completion, to survive a domain reload interrupting an in-progress scan). With detection now instant and the scan scope-limited, the odds of an in-progress scan being interrupted are low enough that this extra machinery is no longer worth the complexity; the flag is consumed at window-open time as before, and a manual re-check via the existing button is a sufficient fallback if a scan is interrupted.

Verification

  • uloop compile: 0 errors, 0 warnings.
  • uloop run-tests (regex filter covering ThirdPartyToolMigration|SetupWizardWindow|DomainReloadRecoveryUseCase|UnityCliLoopEditorSessionStateRepository): 597 tests, 593 passed, 0 failed, 4 skipped.
  • Manual verification (opening the wizard after inducing a real V2-API compile error and a domain reload) has not yet been performed in this PR and is tracked as an outstanding follow-up before the final integration-branch PR merges.

Review in cubic

hatayama added 2 commits July 22, 2026 23:38
ShowWindowForAutoScan consumed the SessionState auto-scan flag the
instant the window opened, before any scan actually ran. If a domain
reload interrupted the scan afterward, the flag was already gone, so
the wizard reopened after the reload with no memory that it still
owed the user a completed scan, and was left showing "Not checked".

The flag is now consumed only once a scan actually reaches a result
state (ShowMigrationTargetsState/ShowNoMigrationTargetsState), or the
window is genuinely closed (OnDestroy, which — unlike OnDisable — does
not fire during a domain reload's serialize/destroy step). CreateGUI
reads the flag (without consuming) as an extra initial-refresh trigger
alongside the existing per-window serialized flag, so a scan
interrupted by a reload restarts on the next CreateGUI instead of
silently getting lost.
… of scanning

Mirror Unity's own API Updater: gate the auto-scan window on
EditorUtility.scriptCompilationFailed and match console error text against
known V2 legacy tokens, instead of unconditionally opening the wizard and
scanning the whole project. Detected file paths seed a scope-limited plan
build (affected assemblies only) instead of a full Assets scan.

Revert the previously implemented flag-lifecycle change (deferred
consumption to survive a domain-reload interruption): with detection now
instant and the scan scope-limited, the probability of an in-progress scan
being interrupted is low enough that the added complexity (composite
ThirdPartyToolMigrationAutoScanState, OnDestroy consume hook, CreateGUI OR
condition) is no longer justified. A manual re-check via the existing button
is a sufficient fallback, and the scan itself remains the authority on
correctness.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5854af62-a339-4c20-b7af-52724b6ab83e

📥 Commits

Reviewing files that changed from the base of the PR and between 7fa57f5 and 76e609a.

📒 Files selected for processing (5)
  • Assets/Tests/Editor/ThirdPartyToolMigrationScopedPreviewTests.cs
  • Assets/Tests/Editor/ThirdPartyToolMigrationWizardWorkflowControllerTests.cs
  • Packages/src/Editor/Domain/ThirdPartyToolMigrationData.cs
  • Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/ThirdPartyToolMigrationFileService.cs
  • Packages/src/Editor/Presentation/Setup/SetupWizardStartupFlow.cs

📝 Walkthrough

Walkthrough

The migration workflow now detects compile-error targets, stores their file paths in session state, and passes them through startup and wizard initialization for a scoped first preview. New parser, assembly-discovery, scoped-preview, and workflow tests cover the behavior.

Changes

Third-party migration auto-scan

Layer / File(s) Summary
Detection and scoped preview
Packages/src/Editor/Domain/..., Packages/src/Editor/Application/..., Packages/src/Editor/Infrastructure/ThirdPartyToolMigration/*, Assets/Tests/Editor/ThirdPartyToolMigration*Tests.cs
Adds compile-error parsing, assembly-structure discovery, compile-error target detection, seed-file-scoped previewing, and coverage for path parsing, assembly resolution, fallback scanning, and scoped scanning.
Session seed storage
Packages/src/Editor/Domain/IThirdPartyToolMigrationAutoScanSeedRepository.cs, Packages/src/Editor/Infrastructure/Settings/...
Defines and implements session-state storage for storing, retrieving, filtering, and clearing auto-scan seed paths.
Startup detection and dependency wiring
Packages/src/Editor/CompositionRoot/*, Packages/src/Editor/Presentation/PresentationEditorStartup.cs, Packages/src/Editor/Presentation/Setup/SetupWizardWindow.cs, Packages/src/Editor/Presentation/Setup/SetupWizardStartupFlow.cs, Assets/Tests/Editor/SetupWizardWindowTests.cs
Threads the seed repository and migration use case through editor startup, detects compile-error targets before scheduling auto-scan, stores detected paths, and removes obsolete boolean-only session-flag tests.
Wizard seed consumption and first preview
Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWindow.cs, Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWorkflowController.cs, Assets/Tests/Editor/ThirdPartyToolMigrationWizardWorkflowControllerTests.cs
Consumes and clears session seeds, passes them into the workflow controller, and uses them only on the first preview refresh.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SetupWizardStartupFlow
  participant ThirdPartyToolMigrationUseCase
  participant ThirdPartyToolMigrationFileService
  participant AutoScanSeedRepository
  participant ThirdPartyToolMigrationWizardWindow
  participant WorkflowController
  SetupWizardStartupFlow->>ThirdPartyToolMigrationUseCase: Detect compile-error targets
  ThirdPartyToolMigrationUseCase->>ThirdPartyToolMigrationFileService: Parse logs and match targets
  ThirdPartyToolMigrationFileService-->>SetupWizardStartupFlow: Target file paths
  SetupWizardStartupFlow->>AutoScanSeedRepository: Store seed paths
  ThirdPartyToolMigrationWizardWindow->>AutoScanSeedRepository: Get and clear seed paths
  ThirdPartyToolMigrationWizardWindow->>WorkflowController: Create with seed paths
  WorkflowController->>ThirdPartyToolMigrationUseCase: Preview migration for seed paths
  WorkflowController->>ThirdPartyToolMigrationUseCase: Preview migration with empty seeds
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: compile-error-based custom-tool migration detection instead of always scanning.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the compile-error gating, scoped scanning, and manual flow.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/migration-flag-lifecycle-and-startup-wiring

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Add wiring-level tests for PreviewMigrationForSeedFilesAsync's
implicit-assembly fallback to a full-project scan (and its contrasting
scope-limited path), a gap flagged as required follow-up when PR-2 was
reviewed.

Remove ISessionFlagsRepository.GetShouldAutoScanThirdPartyToolMigration and
its test fakes: nothing calls it through the interface after reverting the
To-Do 8 flag-lifecycle change, leaving it as dead surface area. The concrete
UnityCliLoopSessionFlagsRepository keeps its own method since
ConsumeShouldAutoScanThirdPartyToolMigration still calls it internally.

Also make TryDetectAutoScanTargetsFromCompileErrors return an empty list
instead of null on a miss, and remove a stray blank line.
@hatayama
hatayama merged commit 05b227f into feature/migration-error-driven-autoscan-integration Jul 22, 2026
1 of 2 checks passed
@hatayama
hatayama deleted the feature/migration-flag-lifecycle-and-startup-wiring branch July 22, 2026 15:33
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