@alpsckr/unitycli 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/contracts/command-contract.json +109 -217
- package/contracts/package-files.json +374 -294
- package/contracts/stable-session/direct-call-semantics.json +8 -2
- package/contracts/tool-completion-contract.json +148 -672
- package/dist/bridge/admission.d.ts +17 -1
- package/dist/bridge/admission.js +2 -0
- package/dist/bridge/admission.js.map +1 -1
- package/dist/bridge/domains/asset.js +3 -1
- package/dist/bridge/domains/asset.js.map +1 -1
- package/dist/bridge/domains/camera.js +39 -7
- package/dist/bridge/domains/camera.js.map +1 -1
- package/dist/bridge/domains/console.js +2 -1
- package/dist/bridge/domains/console.js.map +1 -1
- package/dist/bridge/domains/doctor.d.ts +3 -0
- package/dist/bridge/domains/doctor.js +8 -0
- package/dist/bridge/domains/doctor.js.map +1 -0
- package/dist/bridge/domains/editor.js +0 -4
- package/dist/bridge/domains/editor.js.map +1 -1
- package/dist/bridge/domains/game-object.js +4 -12
- package/dist/bridge/domains/game-object.js.map +1 -1
- package/dist/bridge/domains/graphics.js +1 -16
- package/dist/bridge/domains/graphics.js.map +1 -1
- package/dist/bridge/domains/object.js +3 -0
- package/dist/bridge/domains/object.js.map +1 -1
- package/dist/bridge/domains/physics.js +1 -2
- package/dist/bridge/domains/physics.js.map +1 -1
- package/dist/bridge/domains/profiler.js +18 -7
- package/dist/bridge/domains/profiler.js.map +1 -1
- package/dist/bridge/domains/project-tool.js +4 -0
- package/dist/bridge/domains/project-tool.js.map +1 -1
- package/dist/bridge/domains/reflection.js +10 -2
- package/dist/bridge/domains/reflection.js.map +1 -1
- package/dist/bridge/domains/runtime-tool.js +3 -0
- package/dist/bridge/domains/runtime-tool.js.map +1 -1
- package/dist/bridge/domains/scene.js +3 -8
- package/dist/bridge/domains/scene.js.map +1 -1
- package/dist/bridge/domains/screenshot.js +30 -6
- package/dist/bridge/domains/screenshot.js.map +1 -1
- package/dist/bridge/domains/ui.js +3 -1
- package/dist/bridge/domains/ui.js.map +1 -1
- package/dist/bridge/index.d.ts +5 -5
- package/dist/bridge/index.js +6 -9
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/registry.js +3 -5
- package/dist/bridge/registry.js.map +1 -1
- package/dist/bridge/session-supervisor.d.ts +6 -3
- package/dist/bridge/session-supervisor.js +122 -34
- package/dist/bridge/session-supervisor.js.map +1 -1
- package/dist/bridge/types.d.ts +6 -5
- package/dist/bridge/types.js +16 -2
- package/dist/bridge/types.js.map +1 -1
- package/dist/catalog-protocol.d.ts +64 -0
- package/dist/catalog-protocol.js +460 -0
- package/dist/catalog-protocol.js.map +1 -0
- package/dist/cli-commands/command.js +84 -61
- package/dist/cli-commands/command.js.map +1 -1
- package/dist/cli-commands/extensions.js +70 -50
- package/dist/cli-commands/extensions.js.map +1 -1
- package/dist/cli-commands/instances.js +1 -1
- package/dist/cli-commands/instances.js.map +1 -1
- package/dist/cli-process-owners.d.ts +6 -0
- package/dist/cli-process-owners.js +27 -0
- package/dist/cli-process-owners.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +20 -5
- package/dist/cli.js.map +1 -1
- package/dist/contracts/command-contract.js +14 -4
- package/dist/contracts/command-contract.js.map +1 -1
- package/dist/doctor.d.ts +4 -6
- package/dist/doctor.js +429 -398
- package/dist/doctor.js.map +1 -1
- package/dist/editor-blocker-observer.d.ts +2 -1
- package/dist/editor-blocker-observer.js +40 -13
- package/dist/editor-blocker-observer.js.map +1 -1
- package/dist/extension-availability.d.ts +27 -9
- package/dist/extension-availability.js +96 -56
- package/dist/extension-availability.js.map +1 -1
- package/dist/extensions/descriptor-loader.d.ts +2 -2
- package/dist/extensions/descriptor-loader.js +3 -4
- package/dist/extensions/descriptor-loader.js.map +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/installer.d.ts +24 -7
- package/dist/extensions/installer.js +142 -66
- package/dist/extensions/installer.js.map +1 -1
- package/dist/extensions/registry.js +3 -5
- package/dist/extensions/registry.js.map +1 -1
- package/dist/extensions/state-contract.d.ts +11 -0
- package/dist/extensions/state-contract.js +50 -0
- package/dist/extensions/state-contract.js.map +1 -0
- package/dist/instances.d.ts +13 -1
- package/dist/instances.js +26 -0
- package/dist/instances.js.map +1 -1
- package/dist/package-manager.d.ts +0 -24
- package/dist/package-manager.js +5 -58
- package/dist/package-manager.js.map +1 -1
- package/dist/project-tool-discovery.d.ts +5 -2
- package/dist/project-tool-discovery.js +22 -18
- package/dist/project-tool-discovery.js.map +1 -1
- package/dist/runtime-code.js +1 -1
- package/dist/runtime-code.js.map +1 -1
- package/dist/tool-name.d.ts +4 -0
- package/dist/tool-name.js +15 -0
- package/dist/tool-name.js.map +1 -0
- package/dist/tools/.generated-completion-registry.d.ts +2 -0
- package/dist/tools/.generated-completion-registry.js +763 -325
- package/dist/tools/.generated-completion-registry.js.map +1 -1
- package/dist/tools/.generated-registry.d.ts +6 -11
- package/dist/tools/.generated-registry.js +6 -11
- package/dist/tools/.generated-registry.js.map +1 -1
- package/dist/tools/.generated-schemas.js +11 -16
- package/dist/tools/.generated-schemas.js.map +1 -1
- package/dist/tools/asset/refresh-status.d.ts +3 -0
- package/dist/tools/asset/refresh-status.js +12 -0
- package/dist/tools/asset/refresh-status.js.map +1 -0
- package/dist/tools/asset/refresh.js +7 -3
- package/dist/tools/asset/refresh.js.map +1 -1
- package/dist/tools/build/player-status.d.ts +3 -0
- package/dist/tools/build/player-status.js +12 -0
- package/dist/tools/build/player-status.js.map +1 -0
- package/dist/tools/build/run.js +1 -1
- package/dist/tools/build/run.js.map +1 -1
- package/dist/tools/catalog-control.d.ts +22 -0
- package/dist/tools/catalog-control.js +335 -0
- package/dist/tools/catalog-control.js.map +1 -0
- package/dist/tools/catalog.d.ts +7 -9
- package/dist/tools/catalog.js +66 -45
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/commands.d.ts +1 -1
- package/dist/tools/commands.js +44 -11
- package/dist/tools/commands.js.map +1 -1
- package/dist/tools/define.js +3 -2
- package/dist/tools/define.js.map +1 -1
- package/dist/tools/dispatcher.d.ts +53 -6
- package/dist/tools/dispatcher.js +277 -108
- package/dist/tools/dispatcher.js.map +1 -1
- package/dist/tools/editor/compile.js +1 -1
- package/dist/tools/editor/compile.js.map +1 -1
- package/dist/tools/editor/play-mode-status.d.ts +3 -0
- package/dist/tools/editor/play-mode-status.js +12 -0
- package/dist/tools/editor/play-mode-status.js.map +1 -0
- package/dist/tools/editor/readiness.d.ts +0 -1
- package/dist/tools/editor/readiness.js +0 -1
- package/dist/tools/editor/readiness.js.map +1 -1
- package/dist/tools/editor/refresh.d.ts +7 -3
- package/dist/tools/editor/refresh.js +20 -15
- package/dist/tools/editor/refresh.js.map +1 -1
- package/dist/tools/editor/state.d.ts +2 -2
- package/dist/tools/editor/state.js +13 -12
- package/dist/tools/editor/state.js.map +1 -1
- package/dist/tools/metadata/derived.js +1 -7
- package/dist/tools/metadata/derived.js.map +1 -1
- package/dist/tools/metadata/status.js +1 -12
- package/dist/tools/metadata/status.js.map +1 -1
- package/dist/tools/metadata/types.d.ts +0 -2
- package/dist/tools/navmesh/live.js +1 -1
- package/dist/tools/navmesh/live.js.map +1 -1
- package/dist/tools/occlusion/live.js +1 -1
- package/dist/tools/occlusion/live.js.map +1 -1
- package/dist/tools/package/deploy.js +2 -2
- package/dist/tools/package/deploy.js.map +1 -1
- package/dist/tools/package/embed.js +1 -1
- package/dist/tools/package/embed.js.map +1 -1
- package/dist/tools/package/install-status.d.ts +3 -0
- package/dist/tools/package/install-status.js +12 -0
- package/dist/tools/package/install-status.js.map +1 -0
- package/dist/tools/package/install.js +3 -3
- package/dist/tools/package/install.js.map +1 -1
- package/dist/tools/package/live-resolve.js +45 -12
- package/dist/tools/package/live-resolve.js.map +1 -1
- package/dist/tools/package/registry-clear.js.map +1 -1
- package/dist/tools/package/registry-set.js.map +1 -1
- package/dist/tools/package/remove-status.d.ts +3 -0
- package/dist/tools/package/remove-status.js +12 -0
- package/dist/tools/package/remove-status.js.map +1 -0
- package/dist/tools/package/remove.js +3 -3
- package/dist/tools/package/remove.js.map +1 -1
- package/dist/tools/package/resolve.js +3 -3
- package/dist/tools/package/resolve.js.map +1 -1
- package/dist/tools/package/restore.js +2 -2
- package/dist/tools/package/restore.js.map +1 -1
- package/dist/tools/package/scoped-registry-add.js.map +1 -1
- package/dist/tools/status/support.d.ts +13 -0
- package/dist/tools/status/support.js +28 -0
- package/dist/tools/status/support.js.map +1 -0
- package/dist/tools/test/cancel.js +2 -2
- package/dist/tools/test/cancel.js.map +1 -1
- package/dist/tools/test/run-status.d.ts +3 -0
- package/dist/tools/test/run-status.js +12 -0
- package/dist/tools/test/run-status.js.map +1 -0
- package/dist/tools/test/run.js +7 -4
- package/dist/tools/test/run.js.map +1 -1
- package/dist/tools/tools/group-summaries.js +10 -14
- package/dist/tools/tools/group-summaries.js.map +1 -1
- package/docs/architecture.md +4 -4
- package/docs/availability-differences.md +4 -4
- package/docs/command-execution.md +4 -3
- package/docs/error-codes.md +13 -5
- package/docs/extensions.md +1 -7
- package/docs/risk-and-side-effects.md +4 -3
- package/docs/safety-boundaries.md +3 -1
- package/docs/target-and-instance.md +1 -1
- package/docs/tool-discovery.md +17 -10
- package/docs/tool-execution.md +18 -7
- package/extensions/cinemachine/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/hdrp/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/probuilder/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/urp/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/extensions/vfx-graph/unitypkg/Editor/UnityCliExtensionAssembly.cs +3 -0
- package/package.json +2 -4
- package/skills/unitycli/SKILL.md +35 -42
- package/skills/unitycli/manifest.json +1 -1
- package/skills/unitycli/references/operation-protocol.md +3 -3
- package/unitypkg/Editor/AssemblyInfo.cs +5 -0
- package/unitypkg/Editor/Bridge/BridgeCommandRegistry.cs +49 -14
- package/unitypkg/Editor/Bridge/BridgeHttpServer.cs +9 -35
- package/unitypkg/Editor/Bridge/BridgeQueueState.cs +672 -0
- package/unitypkg/Editor/Bridge/BridgeWorkQueue.cs +970 -120
- package/unitypkg/Editor/BridgeStartupStateMachine.cs +59 -1
- package/unitypkg/Editor/Commands/ProjectToolCommands.cs +4 -0
- package/unitypkg/Editor/Commands/RuntimeToolCommands.cs +3 -0
- package/unitypkg/Editor/Generated/UnityCliToolCompletionRegistry.g.cs +379 -14
- package/unitypkg/Editor/Infrastructure/CodeExecSupport.cs +28 -13
- package/unitypkg/Editor/Infrastructure/RegistryOwnershipResolver.cs +132 -105
- package/unitypkg/Editor/Infrastructure/UnityCliActiveOperation.cs +138 -29
- package/unitypkg/Editor/Infrastructure/UnityCliAdmission.cs +1856 -237
- package/unitypkg/Editor/Infrastructure/UnityCliDoctorDiagnostics.cs +220 -0
- package/unitypkg/Editor/Infrastructure/UnityCliDurableStatusCoordinator.cs +118 -0
- package/unitypkg/Editor/Infrastructure/UnityCliEditorStateSnapshot.cs +2 -1
- package/unitypkg/Editor/Infrastructure/UnityCliHierarchyPager.cs +203 -0
- package/unitypkg/Editor/Infrastructure/UnityCliInstanceCleanup.cs +2 -1
- package/unitypkg/Editor/Infrastructure/UnityCliInstanceRegistry.cs +201 -63
- package/unitypkg/Editor/Infrastructure/UnityCliJson.cs +2 -3
- package/unitypkg/Editor/Infrastructure/UnityCliLiveBuildCoordinator.cs +289 -46
- package/unitypkg/Editor/Infrastructure/UnityCliLiveRefreshCoordinator.cs +87 -53
- package/unitypkg/Editor/Infrastructure/UnityCliNavMeshBakeCoordinator.cs +4 -4
- package/unitypkg/Editor/Infrastructure/UnityCliObjectRef.cs +128 -25
- package/unitypkg/Editor/Infrastructure/UnityCliObjectSerializer.cs +435 -327
- package/unitypkg/Editor/Infrastructure/UnityCliOcclusionBakeCoordinator.cs +4 -4
- package/unitypkg/Editor/Infrastructure/UnityCliOperationCoordinator.cs +351 -53
- package/unitypkg/Editor/Infrastructure/UnityCliPackageResolveCoordinator.cs +118 -18
- package/unitypkg/Editor/Infrastructure/UnityCliPackageResolveState.cs +20 -1
- package/unitypkg/Editor/Infrastructure/UnityCliReadGeneration.cs +97 -0
- package/unitypkg/Editor/Infrastructure/UnityCliReflection.cs +644 -133
- package/unitypkg/Editor/Infrastructure/UnityCliReloadOperation.cs +128 -41
- package/unitypkg/Editor/Infrastructure/UnityCliRuntimeExecutor.cs +14 -84
- package/unitypkg/Editor/Infrastructure/UnityCliSerializer.cs +220 -0
- package/unitypkg/Editor/Infrastructure/UnityCliSessionMutationLease.cs +69 -29
- package/unitypkg/Editor/Infrastructure/UnityCliTestRunCoordinator.cs +440 -54
- package/unitypkg/Editor/Infrastructure/UnityCliWaiter.cs +128 -35
- package/unitypkg/Editor/ProjectTools/IUnityCliTool.cs +9 -1
- package/unitypkg/Editor/ProjectTools/OfficialAttributeToolRegistry.cs +32 -31
- package/unitypkg/Editor/ProjectTools/ProjectToolRegistry.cs +607 -458
- package/unitypkg/Editor/ProjectTools/ProjectToolSchemaValidator.cs +35 -7
- package/unitypkg/Editor/ProjectTools/RegisteredTool.cs +501 -60
- package/unitypkg/Editor/ProjectTools/UnityCliProjectToolContext.cs +21 -0
- package/unitypkg/Editor/ProjectTools/UnityCliSchemaDeriver.cs +36 -7
- package/unitypkg/Editor/ProjectTools/UnityCliToolName.cs +30 -0
- package/unitypkg/Editor/Properties/AssemblyInfo.cs +3 -0
- package/unitypkg/Editor/Tools/asset/get-data.cs +16 -7
- package/unitypkg/Editor/Tools/build/BuildSceneStateTool.cs +23 -3
- package/unitypkg/Editor/Tools/build/BuildToolDtos.cs +2 -1
- package/unitypkg/Editor/Tools/build/scene/add.cs +6 -3
- package/unitypkg/Editor/Tools/build/scene/disable.cs +1 -1
- package/unitypkg/Editor/Tools/build/scene/enable.cs +1 -1
- package/unitypkg/Editor/Tools/build/scene/list.cs +1 -1
- package/unitypkg/Editor/Tools/build/scene/remove.cs +13 -3
- package/unitypkg/Editor/Tools/camera/CameraToolSupport.cs +38 -38
- package/unitypkg/Editor/Tools/camera/multiview.cs +13 -6
- package/unitypkg/Editor/Tools/camera/screenshot.cs +14 -7
- package/unitypkg/Editor/Tools/component/get.cs +16 -9
- package/unitypkg/Editor/Tools/component/modify.cs +6 -4
- package/unitypkg/Editor/Tools/console/clear.cs +7 -6
- package/unitypkg/Editor/Tools/console/get.cs +48 -16
- package/unitypkg/Editor/Tools/editor/EditorToolSupport.cs +143 -28
- package/unitypkg/Editor/Tools/editor/menu-items.cs +1 -1
- package/unitypkg/Editor/Tools/editor/play.cs +2 -11
- package/unitypkg/Editor/Tools/editor/selection.cs +1 -1
- package/unitypkg/Editor/Tools/editor/stop.cs +2 -11
- package/unitypkg/Editor/Tools/editor/windows.cs +1 -1
- package/unitypkg/Editor/Tools/go/GameObjectToolSupport.cs +54 -4
- package/unitypkg/Editor/Tools/go/delete.cs +1 -1
- package/unitypkg/Editor/Tools/go/find.cs +167 -70
- package/unitypkg/Editor/Tools/graphics/GraphicsToolSupport.cs +25 -0
- package/unitypkg/Editor/Tools/graphics/light-probe-group.cs +9 -3
- package/unitypkg/Editor/Tools/graphics/pipeline-info.cs +1 -1
- package/unitypkg/Editor/Tools/graphics/pipeline-settings.cs +1 -1
- package/unitypkg/Editor/Tools/graphics/quality.cs +2 -2
- package/unitypkg/Editor/Tools/graphics/reflection-probe.cs +3 -3
- package/unitypkg/Editor/Tools/graphics/stats.cs +1 -1
- package/unitypkg/Editor/Tools/object/ObjectToolSupport.cs +4 -4
- package/unitypkg/Editor/Tools/object/get-data.cs +9 -7
- package/unitypkg/Editor/Tools/object/modify.cs +7 -5
- package/unitypkg/Editor/Tools/physics/raycast.cs +24 -6
- package/unitypkg/Editor/Tools/prefab/stage.cs +1 -1
- package/unitypkg/Editor/Tools/profiler/ProfilerFrameDebuggerSupport.cs +94 -21
- package/unitypkg/Editor/Tools/profiler/ProfilerMemorySnapshotSupport.cs +397 -10
- package/unitypkg/Editor/Tools/profiler/ProfilerToolSupport.cs +18 -4
- package/unitypkg/Editor/Tools/profiler/frame-debugger/enable.cs +1 -1
- package/unitypkg/Editor/Tools/profiler/frame-debugger/events.cs +88 -87
- package/unitypkg/Editor/Tools/profiler/hierarchy.cs +278 -112
- package/unitypkg/Editor/Tools/profiler/memory-snapshot/compare.cs +9 -5
- package/unitypkg/Editor/Tools/profiler/memory-snapshot/list.cs +37 -35
- package/unitypkg/Editor/Tools/profiler/memory-snapshot/take.cs +99 -97
- package/unitypkg/Editor/Tools/project/info.cs +1 -1
- package/unitypkg/Editor/Tools/project/layers.cs +1 -1
- package/unitypkg/Editor/Tools/project/tags.cs +1 -1
- package/unitypkg/Editor/Tools/reflection/method/call.cs +9 -7
- package/unitypkg/Editor/Tools/reflection/method/find.cs +27 -37
- package/unitypkg/Editor/Tools/reflection/type/schema.cs +24 -28
- package/unitypkg/Editor/Tools/scene/gameobject/component.cs +8 -5
- package/unitypkg/Editor/Tools/scene/gameobject/components.cs +10 -7
- package/unitypkg/Editor/Tools/scene/gameobject-support.cs +104 -8
- package/unitypkg/Editor/Tools/scene/gameobject.cs +37 -16
- package/unitypkg/Editor/Tools/scene/hierarchy.cs +146 -142
- package/unitypkg/Editor/Tools/screenshot/EditorElementCaptureToolSupport.cs +77 -25
- package/unitypkg/Editor/Tools/screenshot/ScreenshotToolSupport.cs +315 -95
- package/unitypkg/Editor/Tools/screenshot/editor-element.cs +7 -5
- package/unitypkg/Editor/Tools/screenshot/game-view.cs +35 -21
- package/unitypkg/Editor/Tools/screenshot/isolated-object.cs +29 -23
- package/unitypkg/Editor/Tools/screenshot/orbit.cs +37 -25
- package/unitypkg/Editor/Tools/screenshot/scene-view.cs +25 -18
- package/unitypkg/Editor/Tools/screenshot/screen.cs +177 -17
- package/unitypkg/Editor/Tools/screenshot/surround.cs +83 -79
- package/unitypkg/Editor/Tools/ui/render-preview.cs +16 -11
- package/unitypkg/Editor/UnityCliBridge.cs +97 -34
- package/unitypkg/Runtime/Infrastructure/UnityCliRuntimeBridge.cs +753 -122
- package/unitypkg/Runtime/Properties/AssemblyInfo.cs +5 -0
- package/unitypkg/Runtime/UnityCli.Runtime.asmdef +1 -1
- package/unitypkg/Shared/AssemblyInfo.cs +4 -0
- package/unitypkg/Shared/UnityCliAdmissionPool.cs +265 -75
- package/unitypkg/Shared/UnityCliBridgeQueuePolicy.cs +410 -0
- package/unitypkg/Shared/UnityCliBridgeWorkItemState.cs +47 -0
- package/unitypkg/Shared/UnityCliExceptionProjection.cs +151 -0
- package/unitypkg/Shared/UnityCliQueuePublication.cs +30 -0
- package/unitypkg/Shared/UnityCliRequestBudget.cs +352 -0
- package/unitypkg/Shared/UnityCliRuntimeRequestPublication.cs +107 -0
- package/unitypkg/Tests/Editor/UnityCli.Editor.Tests.asmdef +2 -2
- package/unitypkg/Tests/Editor/UnityCliAdmissionCoordinatorIntegrationTests.cs +1329 -0
- package/unitypkg/Tests/Editor/UnityCliAdmissionPoolTests.cs +311 -114
- package/unitypkg/Tests/Editor/UnityCliAdmissionRepairStateTests.cs +94 -0
- package/unitypkg/Tests/Editor/UnityCliBridgeAdmissionIntegrationTests.cs +1229 -0
- package/unitypkg/Tests/Editor/UnityCliBridgeQueuePolicyTests.cs +412 -0
- package/unitypkg/Tests/Editor/UnityCliContinuationIntegrationTests.cs +292 -0
- package/unitypkg/Tests/Editor/UnityCliDiagnosticBoundaryTests.cs +120 -0
- package/unitypkg/Tests/Editor/UnityCliDurableStatusTests.cs +84 -0
- package/unitypkg/Tests/Editor/UnityCliExceptionProjectionTests.cs +72 -0
- package/unitypkg/Tests/Editor/UnityCliInstancePublicationRetryTests.cs +180 -97
- package/unitypkg/Tests/Editor/UnityCliMemoryReflectionIntegrationTests.cs +434 -0
- package/unitypkg/Tests/Editor/UnityCliRequestBudgetTests.cs +615 -0
- package/unitypkg/Tests/Editor/UnityCliRuntimeBridgeIntegrationTests.cs +520 -0
- package/unitypkg/Tests/Editor/UnityCliToolCatalogTests.cs +562 -0
- package/unitypkg/Tests/Runtime/UnityCli.Runtime.Tests.asmdef +23 -0
- package/unitypkg/Tests/Runtime/UnityCliRuntimeCatalogValidationTests.cs +29 -0
- package/unitypkg/package.json +1 -1
- package/contracts/static-capability-catalog.json +0 -48226
- package/dist/bridge/domains/diagnose.d.ts +0 -2
- package/dist/bridge/domains/diagnose.js +0 -11
- package/dist/bridge/domains/diagnose.js.map +0 -1
- package/dist/bridge/domains/extension.d.ts +0 -8
- package/dist/bridge/domains/extension.js +0 -20
- package/dist/bridge/domains/extension.js.map +0 -1
- package/dist/capabilities.d.ts +0 -5
- package/dist/capabilities.js +0 -84
- package/dist/capabilities.js.map +0 -1
- package/dist/static-capability-catalog.d.ts +0 -13
- package/dist/static-capability-catalog.js +0 -41
- package/dist/static-capability-catalog.js.map +0 -1
- package/dist/tools/diagnose/capabilities.d.ts +0 -13
- package/dist/tools/diagnose/capabilities.js +0 -34
- package/dist/tools/diagnose/capabilities.js.map +0 -1
- package/dist/tools/package/info.d.ts +0 -19
- package/dist/tools/package/info.js +0 -27
- package/dist/tools/package/info.js.map +0 -1
- package/dist/tools/package/list.d.ts +0 -27
- package/dist/tools/package/list.js +0 -21
- package/dist/tools/package/list.js.map +0 -1
- package/dist/tools/package/registry-get.d.ts +0 -10
- package/dist/tools/package/registry-get.js +0 -22
- package/dist/tools/package/registry-get.js.map +0 -1
- package/dist/tools/package/scoped-registry-list.d.ts +0 -14
- package/dist/tools/package/scoped-registry-list.js +0 -22
- package/dist/tools/package/scoped-registry-list.js.map +0 -1
- package/dist/tools/package/search.d.ts +0 -17
- package/dist/tools/package/search.js +0 -39
- package/dist/tools/package/search.js.map +0 -1
- package/dist/tools/package/status.d.ts +0 -21
- package/dist/tools/package/status.js +0 -37
- package/dist/tools/package/status.js.map +0 -1
- package/dist/tools/tools/describe.d.ts +0 -27
- package/dist/tools/tools/describe.js +0 -35
- package/dist/tools/tools/describe.js.map +0 -1
- package/dist/tools/tools/group-list.d.ts +0 -16
- package/dist/tools/tools/group-list.js +0 -38
- package/dist/tools/tools/group-list.js.map +0 -1
- package/dist/tools/tools/group.d.ts +0 -13
- package/dist/tools/tools/group.js +0 -34
- package/dist/tools/tools/group.js.map +0 -1
- package/dist/tools/tools/pagination.d.ts +0 -17
- package/dist/tools/tools/pagination.js +0 -28
- package/dist/tools/tools/pagination.js.map +0 -1
- package/dist/tools/tools/search.d.ts +0 -15
- package/dist/tools/tools/search.js +0 -42
- package/dist/tools/tools/search.js.map +0 -1
- package/unitypkg/Editor/Tools/diagnose/preflight.cs +0 -269
- package/unitypkg/Editor/Tools/editor/console.cs +0 -26
- package/unitypkg/Editor/Tools/extension/status.cs +0 -87
- package/unitypkg/Editor/Tools/go/inspect.cs +0 -49
- package/unitypkg/Editor/Tools/graphics/pipeline-quality.cs +0 -24
- package/unitypkg/Editor/Tools/graphics/probe-positions.cs +0 -58
- package/unitypkg/Editor/Tools/graphics/settings.cs +0 -104
- package/unitypkg/Editor/Tools/graphics/stats-counters.cs +0 -28
- package/unitypkg/Editor/Tools/graphics/stats-memory.cs +0 -21
- package/unitypkg/Editor/Tools/instances/list.cs +0 -71
- package/unitypkg/Editor/Tools/physics/raycast-all.cs +0 -67
- package/unitypkg/Editor/Tools/scene/build-settings.cs +0 -69
- package/unitypkg/Editor/Tools/scene/data.cs +0 -125
- package/unitypkg/Editor/Tools/tests/list.cs +0 -98
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.IO;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
using System.Reflection;
|
|
8
|
+
using System.Threading;
|
|
9
|
+
using NUnit.Framework;
|
|
10
|
+
using UnityEditor;
|
|
11
|
+
|
|
12
|
+
namespace UnityCli.Tests
|
|
13
|
+
{
|
|
14
|
+
public sealed class UnityCliMemoryReflectionIntegrationTests
|
|
15
|
+
{
|
|
16
|
+
[SetUp]
|
|
17
|
+
public void SetUp()
|
|
18
|
+
{
|
|
19
|
+
FakeMemoryProfiler.Reset();
|
|
20
|
+
ProfilerMemorySnapshotSupport.ResetTestOverrides();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[TearDown]
|
|
24
|
+
public void TearDown()
|
|
25
|
+
{
|
|
26
|
+
FakeMemoryProfiler.Reset();
|
|
27
|
+
ProfilerMemorySnapshotSupport.ResetTestOverrides();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
[Test]
|
|
31
|
+
public void MemorySnapshotTakeCoversAvailableUnavailableUnsupportedAndWriteFailure()
|
|
32
|
+
{
|
|
33
|
+
var root = CreateTestRoot("memory-take");
|
|
34
|
+
try
|
|
35
|
+
{
|
|
36
|
+
ProfilerMemorySnapshotSupport.RootOverrideForTests = root;
|
|
37
|
+
var tool = new ProfilerMemorySnapshotTakeTool();
|
|
38
|
+
|
|
39
|
+
ProfilerToolSupport.MemoryProfilerTypeOverrideForTests = _ => null;
|
|
40
|
+
var missing = Assert.Throws<UnityCliBridge.BridgeCommandException>(() => ExecuteTake(tool, "missing", "missing.snap", null));
|
|
41
|
+
Assert.That(missing.Code, Is.EqualTo("E_PROFILER_PACKAGE_MISSING"));
|
|
42
|
+
AssertInventory(root, 0, 0L);
|
|
43
|
+
|
|
44
|
+
ProfilerToolSupport.MemoryProfilerTypeOverrideForTests = _ => typeof(UnsupportedMemoryProfiler);
|
|
45
|
+
var unsupported = Assert.Throws<UnityCliBridge.BridgeCommandException>(() => ExecuteTake(tool, "unsupported", "unsupported.snap", null));
|
|
46
|
+
Assert.That(unsupported.Code, Is.EqualTo("E_PROFILER_API_UNSUPPORTED"));
|
|
47
|
+
AssertInventory(root, 0, 0L);
|
|
48
|
+
|
|
49
|
+
ProfilerToolSupport.MemoryProfilerTypeOverrideForTests = _ => typeof(FakeMemoryProfiler);
|
|
50
|
+
FakeMemoryProfiler.OnTake = (path, callback) =>
|
|
51
|
+
{
|
|
52
|
+
File.WriteAllBytes(path, new byte[] { 1, 2, 3, 4 });
|
|
53
|
+
callback(path, true);
|
|
54
|
+
};
|
|
55
|
+
var successEffects = 0;
|
|
56
|
+
var result = ExecuteTake(tool, "available", "available.snap", null, () => successEffects++);
|
|
57
|
+
Assert.That(successEffects, Is.EqualTo(1));
|
|
58
|
+
Assert.That(result.SizeBytes, Is.EqualTo(4L));
|
|
59
|
+
Assert.That(result.RetainedCountLimit, Is.EqualTo(100L));
|
|
60
|
+
Assert.That(result.RetainedBytesLimit, Is.EqualTo(8L * 1024L * 1024L * 1024L));
|
|
61
|
+
AssertInventory(root, 1, 4L);
|
|
62
|
+
File.Delete(result.Path);
|
|
63
|
+
|
|
64
|
+
FakeMemoryProfiler.OnTake = (path, callback) => callback(path, true);
|
|
65
|
+
var failureEffects = 0;
|
|
66
|
+
var writeFailure = Assert.Throws<UnityCliBridge.BridgeCommandException>(() =>
|
|
67
|
+
ExecuteTake(tool, "write-failure", "write-failure.snap", null, () => failureEffects++));
|
|
68
|
+
Assert.That(writeFailure.Code, Is.EqualTo("E_PROFILER_SNAPSHOT_ARTIFACT_MISSING"));
|
|
69
|
+
Assert.That(failureEffects, Is.EqualTo(1));
|
|
70
|
+
AssertInventory(root, 0, 0L);
|
|
71
|
+
}
|
|
72
|
+
finally
|
|
73
|
+
{
|
|
74
|
+
DeleteTestRoot(root);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[TestCase("timeout")]
|
|
79
|
+
[TestCase("cancel")]
|
|
80
|
+
[TestCase("reload")]
|
|
81
|
+
public void MemorySnapshotAbandonmentHasOneTerminalAndLateCallbackCannotPublish(string outcome)
|
|
82
|
+
{
|
|
83
|
+
var root = CreateTestRoot("memory-" + outcome);
|
|
84
|
+
try
|
|
85
|
+
{
|
|
86
|
+
ProfilerMemorySnapshotSupport.RootOverrideForTests = root;
|
|
87
|
+
ProfilerToolSupport.MemoryProfilerTypeOverrideForTests = _ => typeof(FakeMemoryProfiler);
|
|
88
|
+
FakeMemoryProfiler.OnTake = (path, callback) => { };
|
|
89
|
+
var terminal = OutcomeException(outcome);
|
|
90
|
+
var effects = 0;
|
|
91
|
+
var tool = new ProfilerMemorySnapshotTakeTool();
|
|
92
|
+
|
|
93
|
+
if (outcome == "cancel")
|
|
94
|
+
{
|
|
95
|
+
Assert.Throws<OperationCanceledException>(() =>
|
|
96
|
+
ExecuteTake(tool, outcome, outcome + ".snap", terminal, () => effects++));
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
{
|
|
100
|
+
var failure = Assert.Throws<UnityCliBridge.BridgeCommandException>(() =>
|
|
101
|
+
ExecuteTake(tool, outcome, outcome + ".snap", terminal, () => effects++));
|
|
102
|
+
Assert.That(failure.Code, Is.EqualTo(outcome == "timeout" ? "E_EXECUTION_TIMEOUT" : "E_EDITOR_RELOADING"));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Assert.That(effects, Is.EqualTo(1));
|
|
106
|
+
Assert.That(FakeMemoryProfiler.Callback, Is.Not.Null);
|
|
107
|
+
AssertInventory(root, 0, 0L);
|
|
108
|
+
|
|
109
|
+
File.WriteAllBytes(FakeMemoryProfiler.PendingPath, new byte[] { 7, 8, 9 });
|
|
110
|
+
FakeMemoryProfiler.Callback(FakeMemoryProfiler.PendingPath, true);
|
|
111
|
+
AssertInventory(root, 0, 0L);
|
|
112
|
+
}
|
|
113
|
+
finally
|
|
114
|
+
{
|
|
115
|
+
DeleteTestRoot(root);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
[Test]
|
|
120
|
+
public void MemorySnapshotListPagesLatestHundredAndRejectsChangedGeneration()
|
|
121
|
+
{
|
|
122
|
+
var root = CreateTestRoot("memory-list");
|
|
123
|
+
try
|
|
124
|
+
{
|
|
125
|
+
ProfilerMemorySnapshotSupport.RootOverrideForTests = root;
|
|
126
|
+
string newest = null;
|
|
127
|
+
for (var index = 0; index < 105; index++)
|
|
128
|
+
{
|
|
129
|
+
var path = Path.Combine(root, "snapshot-" + index.ToString("D3") + ".snap");
|
|
130
|
+
File.WriteAllBytes(path, new[] { (byte)index });
|
|
131
|
+
File.SetLastWriteTimeUtc(path, new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(index));
|
|
132
|
+
newest = path;
|
|
133
|
+
}
|
|
134
|
+
ProfilerMemorySnapshotSupport.ApplyRetention(newest, Budget());
|
|
135
|
+
AssertInventory(root, 100, 100L);
|
|
136
|
+
|
|
137
|
+
var tool = new ProfilerMemorySnapshotListTool();
|
|
138
|
+
var names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
139
|
+
string cursor = null;
|
|
140
|
+
string firstCursor = null;
|
|
141
|
+
var pages = 0;
|
|
142
|
+
do
|
|
143
|
+
{
|
|
144
|
+
var page = tool.ExecuteAsync(
|
|
145
|
+
new ProfilerMemorySnapshotListTool.Request { PageSize = 17, Cursor = cursor },
|
|
146
|
+
Context("memory-list-" + pages.ToString(), null, null)).GetAwaiter().GetResult();
|
|
147
|
+
Assert.That(page.Root, Is.EqualTo(Path.GetFullPath(root)));
|
|
148
|
+
Assert.That(page.Total, Is.EqualTo(100L));
|
|
149
|
+
Assert.That(page.Snapshots.Count, Is.LessThanOrEqualTo(17));
|
|
150
|
+
foreach (var entry in page.Snapshots)
|
|
151
|
+
{
|
|
152
|
+
Assert.That(Path.GetFullPath(entry.Path).StartsWith(Path.GetFullPath(root) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase), Is.True);
|
|
153
|
+
Assert.That(names.Add(entry.Path), Is.True);
|
|
154
|
+
}
|
|
155
|
+
if (pages == 0) firstCursor = page.NextCursor;
|
|
156
|
+
cursor = page.NextCursor;
|
|
157
|
+
pages++;
|
|
158
|
+
} while (cursor != null && pages < 10);
|
|
159
|
+
|
|
160
|
+
Assert.That(cursor, Is.Null);
|
|
161
|
+
Assert.That(pages, Is.EqualTo(6));
|
|
162
|
+
Assert.That(names.Count, Is.EqualTo(100));
|
|
163
|
+
|
|
164
|
+
File.Delete(names.First());
|
|
165
|
+
var stale = Assert.Throws<UnityCliBridge.BridgeCommandException>(() => tool.ExecuteAsync(
|
|
166
|
+
new ProfilerMemorySnapshotListTool.Request { PageSize = 17, Cursor = firstCursor },
|
|
167
|
+
Context("memory-list-stale", null, null)).GetAwaiter().GetResult());
|
|
168
|
+
Assert.That(stale.Code, Is.EqualTo("E_CONTINUATION_STALE"));
|
|
169
|
+
AssertInventory(root, 99, 99L);
|
|
170
|
+
}
|
|
171
|
+
finally
|
|
172
|
+
{
|
|
173
|
+
DeleteTestRoot(root);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
[Test]
|
|
178
|
+
public void RecursiveTypeSchemaPagesAndBoundsDepthMembersDefinitionsBytesTimeAndGeneration()
|
|
179
|
+
{
|
|
180
|
+
var typeName = typeof(RecursiveSchemaFixture).AssemblyQualifiedName;
|
|
181
|
+
var names = new HashSet<string>(StringComparer.Ordinal);
|
|
182
|
+
string cursor = null;
|
|
183
|
+
string firstCursor = null;
|
|
184
|
+
var pages = 0;
|
|
185
|
+
do
|
|
186
|
+
{
|
|
187
|
+
var page = UnityCliBridge.TypeSchemaGenerator.Generate(typeName, 4, 128, 16, 2, cursor, Budget());
|
|
188
|
+
var schema = (Dictionary<string, object>)page.Data["schema"];
|
|
189
|
+
var properties = (Dictionary<string, object>)schema["properties"];
|
|
190
|
+
foreach (var name in properties.Keys) Assert.That(names.Add(name), Is.True);
|
|
191
|
+
if (pages == 0) firstCursor = page.NextCursor;
|
|
192
|
+
cursor = page.NextCursor;
|
|
193
|
+
pages++;
|
|
194
|
+
} while (cursor != null && pages < 20);
|
|
195
|
+
|
|
196
|
+
Assert.That(cursor, Is.Null);
|
|
197
|
+
Assert.That(names.Count, Is.GreaterThanOrEqualTo(5));
|
|
198
|
+
Assert.That(pages, Is.GreaterThan(1));
|
|
199
|
+
|
|
200
|
+
var limited = UnityCliBridge.TypeSchemaGenerator.Generate(typeName, 1, 2, 1, 100, null, Budget());
|
|
201
|
+
Assert.That(limited.Truncated, Is.True);
|
|
202
|
+
Assert.That((long)limited.Data["returnedMemberCount"], Is.LessThanOrEqualTo(2L));
|
|
203
|
+
Assert.That((long)limited.Data["definitionCount"], Is.LessThanOrEqualTo(1L));
|
|
204
|
+
Assert.That(limited.NextCursor, Is.Not.Null.And.Not.Empty);
|
|
205
|
+
|
|
206
|
+
var byteFailure = Assert.Throws<UnityCliRequestBudgetExceededException>(() =>
|
|
207
|
+
UnityCliBridge.TypeSchemaGenerator.Generate(typeName, 4, 128, 16, 100, null, Budget(serialized: 1)));
|
|
208
|
+
Assert.That(byteFailure.Dimension, Is.EqualTo("serializedUtf8Bytes"));
|
|
209
|
+
var timeFailure = Assert.Throws<UnityCliRequestBudgetExceededException>(() =>
|
|
210
|
+
UnityCliBridge.TypeSchemaGenerator.Generate(typeName, 4, 128, 16, 100, null, Budget(milliseconds: 3, clock: new AdvancingClock())));
|
|
211
|
+
Assert.That(timeFailure.Dimension, Is.EqualTo("mainThreadMilliseconds"));
|
|
212
|
+
|
|
213
|
+
UnityCliReadGeneration.InvalidateReflection();
|
|
214
|
+
var stale = Assert.Throws<UnityCliBridge.BridgeCommandException>(() =>
|
|
215
|
+
UnityCliBridge.TypeSchemaGenerator.Generate(typeName, 4, 128, 16, 2, firstCursor, Budget()));
|
|
216
|
+
Assert.That(stale.Code, Is.EqualTo("E_CONTINUATION_STALE"));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
[Test]
|
|
220
|
+
public void ReflectionMethodFindPagesWithoutDuplicatesAndFailsExplicitlyOnZeroProgress()
|
|
221
|
+
{
|
|
222
|
+
var bindings = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static;
|
|
223
|
+
var typeName = typeof(string).AssemblyQualifiedName;
|
|
224
|
+
var signatures = new HashSet<string>(StringComparer.Ordinal);
|
|
225
|
+
string cursor = null;
|
|
226
|
+
string firstCursor = null;
|
|
227
|
+
long total = -1;
|
|
228
|
+
var pages = 0;
|
|
229
|
+
do
|
|
230
|
+
{
|
|
231
|
+
var page = UnityCliBridge.ReflectionInvoker.FindMethods(typeName, null, bindings, 7, cursor, Budget(scans: 10000, nodes: 10000, reflections: 10000));
|
|
232
|
+
if (total < 0L) total = page.Total;
|
|
233
|
+
Assert.That(page.Total, Is.EqualTo(total));
|
|
234
|
+
foreach (var method in page.Methods)
|
|
235
|
+
{
|
|
236
|
+
var signature = method.DeclaringType + "::" + method.Name + "(" + string.Join(",", method.Parameters.Select(item => item.ParameterType).ToArray()) + ")";
|
|
237
|
+
Assert.That(signatures.Add(signature), Is.True, signature);
|
|
238
|
+
}
|
|
239
|
+
if (pages == 0) firstCursor = page.NextCursor;
|
|
240
|
+
cursor = page.NextCursor;
|
|
241
|
+
pages++;
|
|
242
|
+
} while (cursor != null && pages < 200);
|
|
243
|
+
|
|
244
|
+
Assert.That(cursor, Is.Null);
|
|
245
|
+
Assert.That(signatures.Count, Is.EqualTo(total));
|
|
246
|
+
Assert.That(pages, Is.GreaterThan(1));
|
|
247
|
+
|
|
248
|
+
var byteFailure = Assert.Throws<UnityCliRequestBudgetExceededException>(() =>
|
|
249
|
+
UnityCliBridge.ReflectionInvoker.FindMethods(typeName, null, bindings, 7, null, Budget(serialized: 1)));
|
|
250
|
+
Assert.That(byteFailure.Dimension, Is.EqualTo("serializedUtf8Bytes"));
|
|
251
|
+
var timeFailure = Assert.Throws<UnityCliRequestBudgetExceededException>(() =>
|
|
252
|
+
UnityCliBridge.ReflectionInvoker.FindMethods(typeName, null, bindings, 7, null, Budget(milliseconds: 3, clock: new AdvancingClock())));
|
|
253
|
+
Assert.That(timeFailure.Dimension, Is.EqualTo("mainThreadMilliseconds"));
|
|
254
|
+
|
|
255
|
+
UnityCliReadGeneration.InvalidateReflection();
|
|
256
|
+
var stale = Assert.Throws<UnityCliBridge.BridgeCommandException>(() =>
|
|
257
|
+
UnityCliBridge.ReflectionInvoker.FindMethods(typeName, null, bindings, 7, firstCursor, Budget(scans: 10000, nodes: 10000, reflections: 10000)));
|
|
258
|
+
Assert.That(stale.Code, Is.EqualTo("E_CONTINUATION_STALE"));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private static ProfilerMemorySnapshotTakeTool.Result ExecuteTake(
|
|
262
|
+
ProfilerMemorySnapshotTakeTool tool,
|
|
263
|
+
string requestId,
|
|
264
|
+
string path,
|
|
265
|
+
Exception terminalException,
|
|
266
|
+
Action commitEffect = null)
|
|
267
|
+
{
|
|
268
|
+
var waiter = new ImmediateCallbackWaiter(terminalException);
|
|
269
|
+
return tool.ExecuteAsync(
|
|
270
|
+
new ProfilerMemorySnapshotTakeTool.Request { Path = path },
|
|
271
|
+
Context(requestId, waiter, commitEffect ?? (() => { }))).GetAwaiter().GetResult();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private static UnityCliProjectToolContext Context(string requestId, IUnityCliWaiter waiter, Action commitEffect)
|
|
275
|
+
{
|
|
276
|
+
return new UnityCliProjectToolContext
|
|
277
|
+
{
|
|
278
|
+
RequestId = requestId,
|
|
279
|
+
TimeoutMs = 30000,
|
|
280
|
+
CancellationToken = CancellationToken.None,
|
|
281
|
+
Wait = waiter,
|
|
282
|
+
CommitEffectAction = commitEffect
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private static Exception OutcomeException(string outcome)
|
|
287
|
+
{
|
|
288
|
+
if (outcome == "cancel") return new OperationCanceledException("Canceled for test.");
|
|
289
|
+
if (outcome == "reload") return new UnityCliBridge.BridgeCommandException("E_EDITOR_RELOADING", "Domain reload canceled the callback.", "Retry after reload.");
|
|
290
|
+
return new UnityCliBridge.BridgeCommandException("E_EXECUTION_TIMEOUT", "Callback wait timed out.", "Retry or reduce scope.");
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private static UnityCliRequestBudget Budget(
|
|
294
|
+
long scans = 10000,
|
|
295
|
+
long nodes = 4096,
|
|
296
|
+
long getters = 4096,
|
|
297
|
+
long reflections = 4096,
|
|
298
|
+
long serialized = 8 * 1024 * 1024,
|
|
299
|
+
long milliseconds = 2000,
|
|
300
|
+
IUnityCliMonotonicClock clock = null)
|
|
301
|
+
{
|
|
302
|
+
return new UnityCliRequestBudget(new UnityCliReadBudgetInput
|
|
303
|
+
{
|
|
304
|
+
MaxScannedRecords = scans,
|
|
305
|
+
MaxNodes = nodes,
|
|
306
|
+
MaxGetters = getters,
|
|
307
|
+
MaxReflectionCalls = reflections,
|
|
308
|
+
MaxSerializedUtf8Bytes = serialized,
|
|
309
|
+
MaxMainThreadMilliseconds = milliseconds
|
|
310
|
+
}, 30000, CancellationToken.None, clock ?? new FixedClock());
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private static string CreateTestRoot(string suffix)
|
|
314
|
+
{
|
|
315
|
+
var parent = Path.GetFullPath(Path.Combine("Library", "UnityCli", "tests"));
|
|
316
|
+
var root = Path.Combine(parent, "issue-042-" + suffix + "-" + Guid.NewGuid().ToString("N"));
|
|
317
|
+
Directory.CreateDirectory(root);
|
|
318
|
+
return root;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private static void DeleteTestRoot(string root)
|
|
322
|
+
{
|
|
323
|
+
var parent = Path.GetFullPath(Path.Combine("Library", "UnityCli", "tests")) + Path.DirectorySeparatorChar;
|
|
324
|
+
var canonical = Path.GetFullPath(root);
|
|
325
|
+
Assert.That(canonical.StartsWith(parent, StringComparison.OrdinalIgnoreCase), Is.True);
|
|
326
|
+
if (Directory.Exists(canonical)) Directory.Delete(canonical, true);
|
|
327
|
+
Assert.That(Directory.Exists(canonical), Is.False);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private static void AssertInventory(string root, int expectedFiles, long expectedBytes)
|
|
331
|
+
{
|
|
332
|
+
var canonical = Path.GetFullPath(root) + Path.DirectorySeparatorChar;
|
|
333
|
+
var files = Directory.Exists(root)
|
|
334
|
+
? Directory.GetFiles(root, "*", SearchOption.TopDirectoryOnly)
|
|
335
|
+
: Array.Empty<string>();
|
|
336
|
+
Assert.That(files.All(path => Path.GetFullPath(path).StartsWith(canonical, StringComparison.OrdinalIgnoreCase)), Is.True);
|
|
337
|
+
Assert.That(files.Length, Is.EqualTo(expectedFiles));
|
|
338
|
+
Assert.That(files.Sum(path => new FileInfo(path).Length), Is.EqualTo(expectedBytes));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private sealed class ImmediateCallbackWaiter : IUnityCliWaiter
|
|
342
|
+
{
|
|
343
|
+
private readonly Exception terminalException;
|
|
344
|
+
internal ImmediateCallbackWaiter(Exception terminalException) { this.terminalException = terminalException; }
|
|
345
|
+
|
|
346
|
+
public UnityCliMainThreadAwaitable<T> ForCallback<T>(Action<Func<Func<T>, bool>, Func<Exception, bool>> start, TimeSpan timeout, CancellationToken ct = default, Action onAbandoned = null)
|
|
347
|
+
{
|
|
348
|
+
var publication = new UnityCliCallbackPublication<T>();
|
|
349
|
+
start(create => publication.TryComplete(create), error => publication.TryFail(error));
|
|
350
|
+
if (terminalException != null && publication.TryAbandon()) onAbandoned?.Invoke();
|
|
351
|
+
bool completed;
|
|
352
|
+
bool failed;
|
|
353
|
+
T value;
|
|
354
|
+
Exception error;
|
|
355
|
+
publication.Read(out completed, out failed, out value, out error);
|
|
356
|
+
if (terminalException != null) error = terminalException;
|
|
357
|
+
else if (!completed && !failed) error = new InvalidOperationException("The fake callback produced no terminal outcome.");
|
|
358
|
+
return new UnityCliMainThreadAwaitable<T>(new ImmediateSource<T>(value, error));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
public UnityCliMainThreadAwaitable<bool> NextFrame(int frames = 1, CancellationToken ct = default) { throw new NotSupportedException(); }
|
|
362
|
+
public UnityCliMainThreadAwaitable<bool> Delay(TimeSpan duration, CancellationToken ct = default) { throw new NotSupportedException(); }
|
|
363
|
+
public UnityCliMainThreadAwaitable<bool> Until(Func<bool> predicate, TimeSpan timeout, CancellationToken ct = default) { throw new NotSupportedException(); }
|
|
364
|
+
public UnityCliMainThreadAwaitable<bool> UntilStable(Func<bool> predicate, TimeSpan timeout, int minimumFrames = 2, TimeSpan minimumDuration = default, CancellationToken ct = default) { throw new NotSupportedException(); }
|
|
365
|
+
public UnityCliMainThreadAwaitable<bool> UntilEditorReady(TimeSpan timeout, CancellationToken ct = default) { throw new NotSupportedException(); }
|
|
366
|
+
public UnityCliMainThreadAwaitable<bool> UntilPlayModeState(PlayModeStateChange state, TimeSpan timeout, CancellationToken ct = default) { throw new NotSupportedException(); }
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
private sealed class ImmediateSource<T> : IMainThreadAwaitableSource<T>
|
|
370
|
+
{
|
|
371
|
+
private readonly T value;
|
|
372
|
+
private readonly Exception error;
|
|
373
|
+
internal ImmediateSource(T value, Exception error) { this.value = value; this.error = error; }
|
|
374
|
+
public bool IsCompleted { get { return true; } }
|
|
375
|
+
public void RegisterContinuation(Action continuation) { continuation?.Invoke(); }
|
|
376
|
+
public T GetResult()
|
|
377
|
+
{
|
|
378
|
+
if (error != null) throw error;
|
|
379
|
+
return value;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private static class FakeMemoryProfiler
|
|
384
|
+
{
|
|
385
|
+
internal static Action<string, Action<string, bool>> OnTake;
|
|
386
|
+
internal static Action<string, bool> Callback;
|
|
387
|
+
internal static string PendingPath;
|
|
388
|
+
|
|
389
|
+
public static void TakeSnapshot(string path, Action<string, bool> callback)
|
|
390
|
+
{
|
|
391
|
+
PendingPath = path;
|
|
392
|
+
Callback = callback;
|
|
393
|
+
OnTake?.Invoke(path, callback);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
internal static void Reset()
|
|
397
|
+
{
|
|
398
|
+
OnTake = null;
|
|
399
|
+
Callback = null;
|
|
400
|
+
PendingPath = null;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
private static class UnsupportedMemoryProfiler { }
|
|
405
|
+
|
|
406
|
+
private sealed class RecursiveSchemaFixture
|
|
407
|
+
{
|
|
408
|
+
public string Alpha { get; set; }
|
|
409
|
+
public int Beta { get; set; }
|
|
410
|
+
public RecursiveSchemaFixture Next { get; set; }
|
|
411
|
+
public RecursiveSchemaLeaf Leaf { get; set; }
|
|
412
|
+
public Dictionary<string, List<RecursiveSchemaLeaf>> Items { get; set; }
|
|
413
|
+
public RecursiveSchemaLeaf[] Leaves { get; set; }
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
private sealed class RecursiveSchemaLeaf
|
|
417
|
+
{
|
|
418
|
+
public string Value { get; set; }
|
|
419
|
+
public RecursiveSchemaFixture Parent { get; set; }
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
private sealed class FixedClock : IUnityCliMonotonicClock
|
|
423
|
+
{
|
|
424
|
+
public long ElapsedMilliseconds { get { return 0L; } }
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
private sealed class AdvancingClock : IUnityCliMonotonicClock
|
|
428
|
+
{
|
|
429
|
+
private long elapsed;
|
|
430
|
+
public long ElapsedMilliseconds { get { return Interlocked.Increment(ref elapsed); } }
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
#endif
|