Skip to content

fix: The hot-reload warning about edits outside method bodies now says it counts edits since the last compile - #3182

Merged
hatayama merged 5 commits into
feature/hot-reload-large-project-feedbackfrom
fix/hot-reload-trivia-only-drift-warning
Oct 6, 2026
Merged

hatayama merged 5 commits into
feature/hot-reload-large-project-feedbackfrom
fix/hot-reload-trivia-only-drift-warning

Conversation

@hatayama

@hatayama hatayama commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • The hot-reload warning about edits outside method bodies now says that it covers edits made since the last compile.
  • New tests pin that comment-only edits (line, block, and XML documentation comments) never raise this warning.

User Impact

  • Before: after a reload of a file whose only change was an XML documentation comment, a user saw

    Edits outside method bodies in .cs (fields, initializers, or attributes) are not applied by hot reload; run uloop compile to pick them up.

    and read it as being about the comment, so they had to check each time whether a compile was really needed.

  • After:

    Edits outside method bodies in .cs (fields, initializers, or attributes) since the last compile are not applied by hot reload; run uloop compile to pick them up.

    The named form changes the same way, for example Edits outside method bodies in <File>.cs (field initializer: _value) since the last compile are not applied by hot reload; ....

Cause

  • The check compares the edited file with the source of the last compile (the snapshot whose checksum matches the loaded assembly's PDB), not with the file as it was before the current edit. A field, initializer, or attribute edit made earlier and not compiled yet therefore keeps the warning on every later reload, including one that only changes a comment. The old wording did not say which baseline it used.
  • Comments themselves never count: every comparison in the check uses SyntaxFactory.AreEquivalent, which ignores trivia. All new tests passed on their first run against the unchanged check, so the check's logic is not changed.

Changes

  • Both forms of the warning (the file-level one and the one that names members) now include "since the last compile". The test copies of the wording follow: 2 constants and 14 literals that compare the whole sentence.
  • The skill reference (scope-and-limits.md) and docs/hot-reload.md say what the warning compares against and that comment-only edits do not count. The generated skill copies are regenerated from the source.
  • The Known Limits section of docs/hot-reload.md no longer says that other outside-body edits stay silent. As the skill reference already says, they are reported when a verified source baseline is available and stay silent only without one.

Tests

New tests

Each one adds a comment that reaches one comparison of the check and expects no warning:

Test Where the comment goes Comparison it reaches
TransformWorkerClientTests.Run_WithXmlDocCommentOnlyEditOnAMethod_DoesNotEmitOutsideMethodBodyWarning XML documentation comment above an existing method member declarations
TransformWorkerClientTests.Run_WithBlockCommentOnlyEditInsideAFieldInitializer_DoesNotEmitOutsideMethodBodyWarning block comment inside a field initializer field declarators
TransformWorkerClientTests.Run_WithLineCommentOnlyEditAboveAField_DoesNotEmitOutsideMethodBodyWarning line comment on its own line above a field field modifier tokens
TransformWorkerClientTests.Run_WithBlockCommentOnlyEditAfterAFieldType_DoesNotEmitOutsideMethodBodyWarning block comment between a field's type and its name field type
TransformWorkerAddedFieldTests.Drift_LineCommentOnlyEditAboveAFieldAttribute_DoesNotWarn line comment above a field's attribute field attribute lists
TransformWorkerClientTests.Run_WithXmlDocCommentOnlyEditOnTheType_DoesNotEmitOutsideMethodBodyWarning reworded XML documentation comment of the type residual tree
TransformWorkerAddedFieldTests.Drift_DuplicateFieldSyntaxKeyWithCommentOnlyEdit_DoesNotWarn line comment above a duplicated field whole-tree compare used when a duplicate field syntax key makes pairing ambiguous
  • The five client tests check both that the file-level warning is absent and that the drift warnings are empty, because the existing helper only matches the file-level sentence.
  • The attribute test adds the attribute to the snapshot as well, because no field of the compiled host has one. The comment is the only difference between the snapshot and the edited source.
  • The duplicate in the last test repeats a field the compiled type has. A name the compiled type lacks counts as an added field of the edited source and is stripped from that tree only, so that setup warns even when the edited source equals the snapshot (checked locally).

Mutation check

Each comparison was replaced by an ordinal comparison of ToFullString(), which includes trivia, and then reverted.

Mutated comparison Failing tests
Member declarations, field declarators, field modifier tokens, and residual tree at once (TransformWorkerClientTests|TransformWorkerAddedFieldTests, 176 tests) The 5 tests that existed then and Run_WithSnapshotDifferingOnlyByEol_TreatsAllMethodsUnchanged; 170 passed
Member declarations (OutsideMethodBodyDeclarationDiff) Method doc-comment test, EOL test
Field declarators (OutsideMethodBodyFieldGroupDiff) Initializer test
Field modifier tokens (OutsideMethodBodyFieldGroupDiff) Field line-comment test, EOL test
Residual tree (OutsideMethodBodyDriftChecker) Type doc-comment test, duplicate-key test, EOL test
Field type (OutsideMethodBodyFieldGroupDiff, both classes, 180 tests) Field type test only; 179 passed
Field attribute lists (OutsideMethodBodyFieldGroupDiff, both classes, 180 tests) Field attribute test only; 179 passed

Local runs

  • Unity EditMode, filtered:
  • uloop compile: 0 errors. uloop compile-check on the head: 0 errors. Its 7 warnings are in test files this PR does not change.
  • rg "are not applied by hot reload; run uloop compile" finds 18 lines, and all of them say "since the last compile".
  • check-skill-size: no SKILL.md over the limit. The generated copies of scope-and-limits.md are byte-identical to the source (cmp).
  • This PR targets an integration branch, so the build-and-test workflow does not run on it. Code Complexity, File Length, and Dead Code do.

A trial on a large project reported this warning after an edit that only
changed XML documentation comments. The drift check compares declarations
with SyntaxFactory.AreEquivalent, which ignores trivia, so comments should
never count. Each test puts a comment on one of the comparison paths the
check uses: a method's leading trivia, a field initializer, a field's first
modifier, the type's documentation comment, and the whole-tree compare used
when a duplicate field syntax key makes pairing ambiguous.
…compile

The check compares the edited file with the source of the last compile, not
with the file before this edit. An earlier declaration edit therefore keeps
the warning on every reload until uloop compile, and a reader who just changed
a comment took the warning to be about that comment. Both forms of the warning
now name the baseline, and the test copies of the wording follow.
The skill reference and the hot-reload design doc now say that the warning
compares with the source of the last compile, so an earlier declaration edit
keeps it on every reload until uloop compile, and that comment-only edits do
not count. The generated skill copies are regenerated from the source.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: hatayama/unity-cli-loop/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 88ba1b39-8c6e-4175-9f85-69ded5bd0b6c
📥 Commits

Reviewing files that changed from the base of the PR and between f3d6399 and 9424573.

📒 Files selected for processing (3)
  • Assets/Tests/Editor/HotReload/TransformWorkerAddedFieldTests.cs
  • Assets/Tests/Editor/HotReload/TransformWorkerClientTests.cs
  • docs/hot-reload.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/hot-reload.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Outside-method-body drift warnings now specify that edits occurred since the last compile. Tests cover comment-only edits, and the hot-reload guidance describes the comparison source and warning behavior across reloads.

Changes

Outside-method-body drift warnings

Layer / File(s) Summary
Warning wording, tests, and documentation
Packages/src/Editor/FirstPartyTools/HotReload/TransformWorker~/OutsideMethodBodyDriftChecker.cs, Assets/Tests/Editor/HotReload/TransformWorker*Tests.cs, .agents/skills/uloop-hot-reload/references/scope-and-limits.md, .claude/skills/uloop-hot-reload/references/scope-and-limits.md, Packages/src/Editor/FirstPartyTools/HotReload/Skill/references/scope-and-limits.md, docs/hot-reload.md
Warning messages and expected text specify “since the last compile.” Regression tests check that comment-only edits do not produce declaration-drift warnings. The guidance says warnings compare against the source used to compile the loaded assembly and persist until uloop compile.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 94245

The warning, documentation, and regression tests align with the checker’s last-compile baseline and comment-only behavior. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 88.46% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 3 files. (1 skipped: 1 …
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.
Title check ✅ Passed The title clearly describes the main change: clarifying that hot-reload warnings cover edits since the last compile. It is somewhat long, but remains specific and readable.
Description check ✅ Passed The description explains the warning wording change, comment-only edit behavior, related tests, documentation updates, and validation results.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

…e warning

The outside-method-body check also compares a field's type and its attribute
lists, and no test covered either comparison. A block comment after the type
and a line comment above an attribute now pin that both ignore comments.
The Known Limits entry still said that edits outside method bodies other
than const changes stay silent, which contradicts the warning described
earlier in the same document and in the skill reference. Such edits are
reported when a verified source baseline is available and stay silent only
without one.
@hatayama
hatayama merged commit c847dc7 into feature/hot-reload-large-project-feedback Oct 6, 2026
5 checks passed
@hatayama
hatayama deleted the fix/hot-reload-trivia-only-drift-warning branch October 6, 2026 09:08
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