Namespace Serenity.Editor.ObsoleteAssetCleaner
Classes
SerenityObsoleteAssetCleaner
Removes leftovers from previous package versions after an upgrade. Unity's .unitypackage import
is additive — it never deletes files — so a customer upgrading over an older install keeps orphaned
scripts that no longer compile against the current codebase. The package owns
Assets/Serenity/Scripts, Tests and Documentation outright
(see Serenity.Editor.ObsoleteAssetCleaner.SerenityFrameworkOwnership): any file under those roots that is not listed in the
shipped ShippedAssetsSnapshot.json is an orphan and is moved to the OS trash (recoverable).
The cleaner lives in an isolated assembly with no references to any other Serenity assembly so it
keeps compiling — and keeps cleaning — even when a stale orphan breaks another assembly.
SerenityPackageImportScrubber
Scorched-earth package updater: the Serenity package is the sole owner of
Assets/Serenity/Scripts, Tests and Documentation, so when a Serenity package
import starts this scrubber moves those folders to the OS trash (recoverable) and lets the import lay
everything down fresh — no orphans, no GUID hostages, no compile errors, no restart. Media/ is
never touched (users modify prefabs and themes in place). A post-import safety net additionally trashes
any leftover files under the same roots that were not part of the import, covering editor versions
where the pre-import hook fires after files land. Deleting the running scrubber's own sources is safe:
the loaded assembly stays in the domain for the rest of the session, and the import restores the files.
Accepted destructive edge: partial Custom Package imports of the framework folders are UNSUPPORTED —
a file the user deselects during a Serenity import is not part of the imported items, so the safety
net treats the on-disk copy as a leftover and moves it to the trash (recoverable). This is a product
decision, not an accident: those folders belong to the package, and deselecting framework files would
otherwise leave exactly the stale-orphan states this mechanism exists to eliminate.
SerenityShippedSnapshotImportWatcher
Re-triggers the cleanup when a Serenity package update lands in an editor where the cleaner is already
resident: importing a new package brings a new ShippedAssetsSnapshot.json, and reacting to its
import lets the update self-apply (sweep + restore) without a manual editor restart.