From 16b405c2eb34813537fec0259b8a64b3d06a6cea Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sat, 4 Mar 2023 23:13:46 +0900 Subject: [PATCH 1/8] chore: add assertion after migration --- Editor/Migration/Migration.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Editor/Migration/Migration.cs b/Editor/Migration/Migration.cs index 1f9499312..eb5ec8d42 100644 --- a/Editor/Migration/Migration.cs +++ b/Editor/Migration/Migration.cs @@ -330,8 +330,12 @@ private static void MigrateSet( renderersSet.Clear(); - foreach (var value in values) + var valuesSet = new HashSet(values); + + foreach (var value in valuesSet) renderersSet.GetElementOf(value).EnsureAdded(); + + Assert.IsTrue(valuesSet.SetEquals(renderersSet.Values)); } private static void MigrateList(SerializedProperty arrayProperty, SerializedProperty listProperty, From fd659fe5a2880e51443a7facfe5cfe19f169966b Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sat, 4 Mar 2023 23:17:10 +0900 Subject: [PATCH 2/8] chore: add migration error reason --- Editor/Migration/Migration.cs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Editor/Migration/Migration.cs b/Editor/Migration/Migration.cs index eb5ec8d42..be4fd4e40 100644 --- a/Editor/Migration/Migration.cs +++ b/Editor/Migration/Migration.cs @@ -155,8 +155,15 @@ private static void MigratePrefabs(List prefabAssets, Action()) - modified |= MigrateComponent(component); + try + { + foreach (var component in prefabAsset.GetComponentsInChildren()) + modified |= MigrateComponent(component); + } + catch (Exception e) + { + throw new Exception($"Migrating Prefab {prefabAsset.name}: {e.Message}", e); + } if (modified) PrefabUtility.SavePrefabAsset(prefabAsset); @@ -175,9 +182,18 @@ private static void MigrateAllScenes(List scenePaths, Action()) - modified |= MigrateComponent(component); + + try + { + foreach (var rootGameObject in scene.GetRootGameObjects()) + foreach (var component in rootGameObject.GetComponentsInChildren()) + modified |= MigrateComponent(component); + } + catch (Exception e) + { + throw new Exception($"Migrating Scene {scene.name}: {e.Message}", e); + } + if (modified) EditorSceneManager.SaveScene(scene); } From 692d5bc2784e023797d249d279b417522de5f54a Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sat, 4 Mar 2023 23:42:31 +0900 Subject: [PATCH 3/8] test: add test about Clear --- Test~/PrefabSafeSet/EditorUtil.cs | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Test~/PrefabSafeSet/EditorUtil.cs b/Test~/PrefabSafeSet/EditorUtil.cs index 218a21116..b7a28a99a 100644 --- a/Test~/PrefabSafeSet/EditorUtil.cs +++ b/Test~/PrefabSafeSet/EditorUtil.cs @@ -291,5 +291,40 @@ public void InstanceElements() } #endregion + + #region Elements + + [Test] + public void PrefabClear() + { + using (var scope = new PSSTestUtil.Scope()) + { + scope.PrefabEditorUtil.Clear(); + Assert.That(scope.PrefabEditorUtil.Count, Is.EqualTo(5)); + } + } + + [Test] + public void VariantClear() + { + using (var scope = new PSSTestUtil.Scope()) + { + scope.VariantEditorUtil.Clear(); + Assert.That(scope.VariantEditorUtil.Count, Is.EqualTo(5)); + } + } + + + [Test] + public void InstanceClear() + { + using (var scope = new PSSTestUtil.Scope()) + { + scope.InstanceEditorUtil.Clear(); + Assert.That(scope.InstanceEditorUtil.Count, Is.EqualTo(5)); + } + } + + #endregion } } From 83cfac17f75becb9723f3ec49e17fab747fc7737 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 5 Mar 2023 00:00:49 +0900 Subject: [PATCH 4/8] test: enable coverage --- .github/workflows/gameci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/gameci.yml b/.github/workflows/gameci.yml index 6577fdb6c..fb8ba911d 100644 --- a/.github/workflows/gameci.yml +++ b/.github/workflows/gameci.yml @@ -41,9 +41,8 @@ jobs: with: name: Test results path: ${{ steps.gameci.outputs.artifactsPath }} - # Coverage not supported on unity 2019 - #- uses: actions/upload-artifact@v3 - # if: always() - # with: - # name: Coverage results - # path: ${{ steps.ganmeci.outputs.coveragePath }} + - uses: actions/upload-artifact@v3 + if: always() + with: + name: Coverage results + path: ${{ steps.gameci.outputs.coveragePath }} From 65cc2ffbe489cf9dbb8f19f60ec69a72801e3395 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 5 Mar 2023 00:13:55 +0900 Subject: [PATCH 5/8] docs: changelog --- CHANGELOG-PRERELEASE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index a3140b2a3..973c4e93f 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog]. ### Removed ### Fixed +- Migration of PrefabSafeSet prefab overrides is not well `#29``` ### Security From fb5afb10bff820ef4bb5c8cedb23a684075191e4 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 5 Mar 2023 00:26:07 +0900 Subject: [PATCH 6/8] fix: 'Clear' does not clear elements --- Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs b/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs index 597b1e64d..8ec1ef9fb 100644 --- a/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs +++ b/Internal/PrefabSafeSet/Editor/EditorUtil.PrefabModification.cs @@ -251,7 +251,7 @@ public void DoInitialize() public override void Clear() { Initialize(); - for (var i = _elements.Count - 1; i >= _upstreamElementCount; i--) + for (var i = _elements.Count - 1; i >= 0; i--) _elements[i].EnsureRemoved(); _currentAdditionsSize = _currentAdditions.arraySize = 0; } From 350736f8cb2fa01ab905ba57212580a2877a75ec Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 5 Mar 2023 00:38:59 +0900 Subject: [PATCH 7/8] test: 'Clear' should make count zero --- Test~/PrefabSafeSet/EditorUtil.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Test~/PrefabSafeSet/EditorUtil.cs b/Test~/PrefabSafeSet/EditorUtil.cs index b7a28a99a..0ca444246 100644 --- a/Test~/PrefabSafeSet/EditorUtil.cs +++ b/Test~/PrefabSafeSet/EditorUtil.cs @@ -300,7 +300,7 @@ public void PrefabClear() using (var scope = new PSSTestUtil.Scope()) { scope.PrefabEditorUtil.Clear(); - Assert.That(scope.PrefabEditorUtil.Count, Is.EqualTo(5)); + Assert.That(scope.PrefabEditorUtil.Count, Is.EqualTo(0)); } } @@ -310,7 +310,7 @@ public void VariantClear() using (var scope = new PSSTestUtil.Scope()) { scope.VariantEditorUtil.Clear(); - Assert.That(scope.VariantEditorUtil.Count, Is.EqualTo(5)); + Assert.That(scope.VariantEditorUtil.Count, Is.EqualTo(0)); } } @@ -321,7 +321,7 @@ public void InstanceClear() using (var scope = new PSSTestUtil.Scope()) { scope.InstanceEditorUtil.Clear(); - Assert.That(scope.InstanceEditorUtil.Count, Is.EqualTo(5)); + Assert.That(scope.InstanceEditorUtil.Count, Is.EqualTo(0)); } } From 4eb469a80a24cba20af28a7a27b8c41230e6dcb5 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 5 Mar 2023 00:43:12 +0900 Subject: [PATCH 8/8] docs: bad quote --- CHANGELOG-PRERELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 973c4e93f..8eb325507 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -16,7 +16,7 @@ The format is based on [Keep a Changelog]. ### Removed ### Fixed -- Migration of PrefabSafeSet prefab overrides is not well `#29``` +- Migration of PrefabSafeSet prefab overrides is not well `#29` ### Security