fix: Compile reports assembly definition errors instead of unknown status#1260
Conversation
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.
📝 WalkthroughWalkthroughCompileController 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. ChangesCompilation stopped-without-finish result handling
🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs (1)
167-194: ⚡ Quick winAdd a force-compile branch test for stopped-without-finish results.
The helper now branches on
isForceCompile, but this suite only exercisesfalse. A focused test fortruewould 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
📒 Files selected for processing (2)
Assets/Tests/Editor/CompileLifecycleWatchdogTests.csPackages/src/Editor/FirstPartyTools/Compile/CompileController.cs
Summary
User Impact
Changes
Verification