Repository navigation
chore: Separate editor settings storage from domain values - #1581
Conversation
Keep editor settings behavior and JSON shape unchanged while moving JsonUtility storage into an infrastructure DTO and making the domain settings record init-only. Add the Unity IsExternalInit marker needed for init accessors in the Domain assembly.
📝 WalkthroughWalkthroughIntroduces a JSON DTO ( ChangesSettings JSON DTO Introduction
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant Repository as UnityCliLoopEditorSettingsRepository
participant Dto as UnityCliLoopEditorSettingsJsonData
participant JsonUtility
Client->>Repository: SaveSettings(domainData)
Repository->>Dto: FromDomain(domainData)
Repository->>JsonUtility: ToJson(dto)
Repository-->>Client: file written
Client->>Repository: LoadSettings()
Repository->>JsonUtility: FromJson<JsonData>(json)
Repository->>Dto: ToDomain()
Repository-->>Client: domainData
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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)
Packages/src/Editor/Domain/IsExternalInit.cs (1)
1-7: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStandard init-accessor shim — LGTM.
This is the well-known workaround for
initaccessors on runtimes lacking the built-inIsExternalInitmarker; declaring itinternalin this assembly is sufficient for the Domain assembly's own use.One thing worth keeping in mind going forward: because this type is
internal, it is only visible within this assembly. If another assembly (e.g. Infrastructure or Application) later wants its ownrecord/initproperties, it will need its own copy of this shim (or a shared, referenced one) since internal types don't cross assembly boundaries.🤖 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 `@Packages/src/Editor/Domain/IsExternalInit.cs` around lines 1 - 7, The IsExternalInit shim is declared internal in the Domain assembly, so it will not be available to other assemblies that may later use record or init accessors. If cross-assembly support is intended, add the same shim to each consuming assembly or move it into a shared referenced assembly; otherwise keep it as-is and ensure only the Domain assembly relies on it. Reference the IsExternalInit type in System.Runtime.CompilerServices when making the decision.
🤖 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 `@Packages/src/Editor/Domain/IsExternalInit.cs`:
- Around line 1-7: The IsExternalInit shim is declared internal in the Domain
assembly, so it will not be available to other assemblies that may later use
record or init accessors. If cross-assembly support is intended, add the same
shim to each consuming assembly or move it into a shared referenced assembly;
otherwise keep it as-is and ensure only the Domain assembly relies on it.
Reference the IsExternalInit type in System.Runtime.CompilerServices when making
the decision.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 66980509-da4c-40be-a05c-bcc0c30ca14f
⛔ Files ignored due to path filters (2)
Packages/src/Editor/Domain/IsExternalInit.cs.metais excluded by none and included by nonePackages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsJsonData.cs.metais excluded by none and included by none
📒 Files selected for processing (6)
Assets/Tests/Editor/OnionAssemblyDependencyTests.csAssets/Tests/Editor/UnityCliLoopEditorSettingsRecoveryTests.csPackages/src/Editor/Domain/IsExternalInit.csPackages/src/Editor/Domain/UnityCliLoopEditorSettingsData.csPackages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsJsonData.csPackages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsRepository.cs
There was a problem hiding this comment.
1 issue found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsJsonData.cs">
<violation number="1" location="Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsJsonData.cs:38">
P3: FromDomain is an internal method, so the ArgumentNullException throw after the Debug.Assert is redundant and adds unnecessary exception surface. The project convention for internal APIs is to enforce preconditions with Debug.Assert alone. Remove the `if (settings == null)` guard and let the assert serve as the contract check.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }; | ||
| } | ||
|
|
||
| internal static UnityCliLoopEditorSettingsJsonData FromDomain(UnityCliLoopEditorSettingsData settings) |
There was a problem hiding this comment.
P3: FromDomain is an internal method, so the ArgumentNullException throw after the Debug.Assert is redundant and adds unnecessary exception surface. The project convention for internal APIs is to enforce preconditions with Debug.Assert alone. Remove the if (settings == null) guard and let the assert serve as the contract check.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Packages/src/Editor/Infrastructure/Settings/UnityCliLoopEditorSettingsJsonData.cs, line 38:
<comment>FromDomain is an internal method, so the ArgumentNullException throw after the Debug.Assert is redundant and adds unnecessary exception surface. The project convention for internal APIs is to enforce preconditions with Debug.Assert alone. Remove the `if (settings == null)` guard and let the assert serve as the contract check.</comment>
<file context>
@@ -0,0 +1,60 @@
+ };
+ }
+
+ internal static UnityCliLoopEditorSettingsJsonData FromDomain(UnityCliLoopEditorSettingsData settings)
+ {
+ Debug.Assert(settings != null, "settings must not be null");
</file context>
Summary
User Impact
Changes
Review Notes
Verification
dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type exact --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.UnityCliLoopEditorSettingsRecoveryTests"dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type exact --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.UnityCliLoopPackageRemovalSettingsResetterTests"dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type exact --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.SetupWizardWindowTests"dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type exact --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.OnionAssemblyDependencyTests"dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type exact --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.UnityCliLoopSettingsWindowCliActionTests"