Skip to content

fix: Compile reports assembly definition errors instead of unknown status#1260

Merged
hatayama merged 1 commit into
v3-betafrom
feature/hatayama/fix-compile-indeterminate-result
Jun 1, 2026
Merged

fix: Compile reports assembly definition errors instead of unknown status#1260
hatayama merged 1 commit into
v3-betafrom
feature/hatayama/fix-compile-indeterminate-result

Conversation

@hatayama

@hatayama hatayama commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Compile now reports current assembly definition import errors when Unity stops compiling before the finish callback.
  • The existing compile status polling flow remains unchanged, but known assembly definition failures are returned as actionable compile errors.

User Impact

  • Before, compile could return an indeterminate result and ask users to inspect logs even when Unity already had a concrete assembly definition error.
  • Now those known assembly definition errors are surfaced directly in the compile response, making the next fix step clear without an extra log lookup.

Changes

  • Re-check current assembly definition Console errors in the missed finish-callback recovery path.
  • Preserve the previous unknown-result behavior when no known assembly definition error explains the callback gap.
  • Add focused EditMode coverage for both the actionable-error path and the remaining indeterminate path.

Verification

  • cli/dist/darwin-arm64/uloop compile --project-path <PROJECT_ROOT>
  • cli/dist/darwin-arm64/uloop run-tests --project-path <PROJECT_ROOT> --test-mode EditMode --filter-type regex --filter-value ".CompileLifecycleWatchdogTests."
  • codex-review v3-beta --parallel-tests "cli/dist/darwin-arm64/uloop run-tests --project-path <PROJECT_ROOT> --test-mode EditMode --filter-type regex --filter-value '.CompileLifecycleWatchdogTests.'"

When Unity stops compiling before the compilationFinished callback, keep the compile status polling flow intact but classify current asmdef Console errors as actionable compile failures instead of unknown results.
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

CompileController now uses new static helpers to handle compilation that stops before the finish callback. The refactor checks for ASMDEF errors first and builds indeterminate results from captured compiler messages, replacing prior instance-based construction. The event handler updates logging with result-computed messages and error counts. Two new tests validate the helper behavior for ASMDEF-error and indeterminate cases.

Changes

Compilation stopped-without-finish result handling

Layer / File(s) Summary
Static helper methods for stopped-without-finish results
Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
CreateStoppedWithoutFinishResult selects between ASMDEF failure and indeterminate-from-messages outcomes; CreateIndeterminateCompileResultFromMessages computes message and error fields while omitting details when forced compilation is enabled.
Event handler refactoring to use result helpers
Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
HandleCompileStoppedWithoutFinishEvent now calls the new static helpers to compute a concrete CompileResult, improves warning logs with result-computed messages and ASMDEF error counts, and aborts compilation using the computed result.
Unit test coverage for result creation behavior
Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs
Import of UnityEditor.Compilation namespace added; two tests validate CreateStoppedWithoutFinishResult outcomes: one confirms ASMDEF import errors map to failure results with expected counts and messages, the other confirms indeterminate results preserve compiler error details when ASMDEF errors are absent.

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • hatayama/unity-cli-loop#1225: Both PRs modify CompileController's handling of Assembly Definition console errors by converting/using asmdef-related error data to shape CompileResult outcomes, and the main PR's new stopped-without-finish tests align with the retrieved PR's asmdef error detection/mapping flow.
  • hatayama/unity-cli-loop#1237: The main PR's refactor of CompileController's "stopped without finish" handling directly builds on the retrieved PR's lifecycle watchdog and missed-finish-callback recovery, with expanded CompileLifecycleWatchdogTests coverage in the same areas.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% 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 and concisely summarizes the main change: compile now reports assembly definition errors instead of returning unknown status when finish callback is missed.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem, solution, user impact, and verification steps for the assembly definition error reporting feature.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/hatayama/fix-compile-indeterminate-result

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs (1)

167-194: ⚡ Quick win

Add a force-compile branch test for stopped-without-finish results.

The helper now branches on isForceCompile, but this suite only exercises false. A focused test for true would lock in the “counts preserved, details hidden” contract.

Proposed test addition
+        [Test]
+        public void CreateStoppedWithoutFinishResult_WhenForceCompileTrue_HidesMessageDetails()
+        {
+            AssemblyDefinitionConsoleErrorResult assemblyDefinitionResult =
+                new(new AssemblyDefinitionConsoleError[0]);
+            CompilerMessage[] compilerMessages =
+            {
+                new()
+                {
+                    type = CompilerMessageType.Error,
+                    message = "CS0001: hidden on force compile",
+                    file = "Assets/Scripts/Sample.cs",
+                    line = 10
+                }
+            };
+
+            CompileResult result = CompileController.CreateStoppedWithoutFinishResult(
+                assemblyDefinitionResult,
+                compilerMessages,
+                true,
+                "Compilation stopped before the finish callback.");
+
+            Assert.That(result.IsIndeterminate, Is.True);
+            Assert.That(result.ErrorCount, Is.EqualTo(1));
+            Assert.That(result.Messages, Is.Empty);
+            Assert.That(result.Errors, Is.Empty);
+            Assert.That(result.Warnings, Is.Empty);
+        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs` around lines 167 - 194,
Add a new unit test in CompileLifecycleWatchdogTests that mirrors the existing
CreateStoppedWithoutFinishResult_WhenNoAsmdefErrorsExist_ReturnsIndeterminateMessages
but passes isForceCompile = true to
CompileController.CreateStoppedWithoutFinishResult; assert the returned
CompileResult still has Success == null, IsIndeterminate == true, ErrorCount
equals the original compilerMessages length (counts preserved) and that the
Errors array preserves length but the error detail is hidden (e.g.,
Errors[0].message is not the original "CS0000: sample compile error" or is
null/empty), thereby validating the “counts preserved, details hidden” behavior
of CompileController.CreateStoppedWithoutFinishResult when isForceCompile is
true.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs`:
- Around line 167-194: Add a new unit test in CompileLifecycleWatchdogTests that
mirrors the existing
CreateStoppedWithoutFinishResult_WhenNoAsmdefErrorsExist_ReturnsIndeterminateMessages
but passes isForceCompile = true to
CompileController.CreateStoppedWithoutFinishResult; assert the returned
CompileResult still has Success == null, IsIndeterminate == true, ErrorCount
equals the original compilerMessages length (counts preserved) and that the
Errors array preserves length but the error detail is hidden (e.g.,
Errors[0].message is not the original "CS0000: sample compile error" or is
null/empty), thereby validating the “counts preserved, details hidden” behavior
of CompileController.CreateStoppedWithoutFinishResult when isForceCompile is
true.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd20b6d4-d6ef-413e-9145-f7147e339997

📥 Commits

Reviewing files that changed from the base of the PR and between 2254286 and 59ff7ea.

📒 Files selected for processing (2)
  • Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@hatayama
hatayama merged commit e093b0b into v3-beta Jun 1, 2026
10 checks passed
@hatayama
hatayama deleted the feature/hatayama/fix-compile-indeterminate-result branch June 1, 2026 14:56
@github-actions github-actions Bot mentioned this pull request Jun 1, 2026
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