com.wallstop-studios.unity-helpers 2.1.0 → 2.1.2
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/AGENTS.md +1 -0
- package/Docs/ILIST_SORTING_PERFORMANCE.md +92 -0
- package/{package-lock.json.meta → Docs/ILIST_SORTING_PERFORMANCE.md.meta} +1 -1
- package/Docs/INDEX.md +11 -1
- package/Docs/Images/random_generators.svg +7 -7
- package/Docs/RANDOM_PERFORMANCE.md +17 -14
- package/Docs/REFLECTION_HELPERS.md +84 -1
- package/Docs/REFLECTION_PERFORMANCE.md +169 -0
- package/Docs/REFLECTION_PERFORMANCE.md.meta +7 -0
- package/Docs/RELATIONAL_COMPONENTS.md +6 -0
- package/Docs/RELATIONAL_COMPONENT_PERFORMANCE.md +63 -0
- package/Docs/RELATIONAL_COMPONENT_PERFORMANCE.md.meta +7 -0
- package/Docs/SPATIAL_TREE_2D_PERFORMANCE.md +64 -64
- package/Docs/SPATIAL_TREE_3D_PERFORMANCE.md +64 -64
- package/Editor/Core/Helper/AnimationEventHelpers.cs +1 -1
- package/Editor/Sprites/AnimationCopier.cs +1 -1
- package/Editor/Sprites/AnimationViewerWindow.cs +4 -4
- package/Editor/Sprites/SpriteSettingsApplierAPI.cs +2 -1
- package/Editor/Sprites/TextureResizerWizard.cs +4 -3
- package/Editor/Utils/ScriptableObjectSingletonCreator.cs +3 -3
- package/README.md +33 -18
- package/Runtime/Core/Attributes/BaseRelationalComponentAttribute.cs +147 -20
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs +630 -117
- package/Runtime/Core/Attributes/NotNullAttribute.cs +5 -2
- package/Runtime/Core/Attributes/ParentComponentAttribute.cs +477 -103
- package/Runtime/Core/Attributes/RelationalComponentAssigner.cs +26 -3
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +19 -3
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +265 -92
- package/Runtime/Core/CodeGen.meta +8 -0
- package/Runtime/Core/DataStructure/ImmutableBitSet.cs +5 -20
- package/Runtime/Core/Extension/IListExtensions.cs +720 -12
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +11 -7
- package/Runtime/Core/Helper/Objects.cs +1 -1
- package/Runtime/Core/Helper/ReflectionHelpers.Factory.cs +5142 -0
- package/Runtime/Core/Helper/ReflectionHelpers.Factory.cs.meta +11 -0
- package/Runtime/Core/Helper/ReflectionHelpers.cs +1812 -1518
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +2 -3
- package/Runtime/Core/Math/Line2D.cs +2 -4
- package/Runtime/Core/Math/Line3D.cs +2 -4
- package/Runtime/Core/Random/AbstractRandom.cs +52 -5
- package/Runtime/Core/Random/DotNetRandom.cs +3 -3
- package/Runtime/Core/Random/FlurryBurstRandom.cs +279 -0
- package/Runtime/Core/Random/FlurryBurstRandom.cs.meta +3 -0
- package/Runtime/Core/Random/IllusionFlow.cs +3 -3
- package/Runtime/Core/Random/LinearCongruentialGenerator.cs +3 -3
- package/Runtime/Core/Random/PcgRandom.cs +6 -6
- package/Runtime/Core/Random/PhotonSpinRandom.cs +387 -0
- package/Runtime/Core/Random/PhotonSpinRandom.cs.meta +3 -0
- package/Runtime/Core/Random/RomuDuo.cs +3 -3
- package/Runtime/Core/Random/SplitMix64.cs +3 -3
- package/Runtime/Core/Random/SquirrelRandom.cs +6 -4
- package/Runtime/Core/Random/StormDropRandom.cs +271 -0
- package/Runtime/Core/Random/StormDropRandom.cs.meta +3 -0
- package/Runtime/Core/Random/UnityRandom.cs +3 -3
- package/Runtime/Core/Random/WyRandom.cs +6 -4
- package/Runtime/Core/Random/XorShiftRandom.cs +3 -3
- package/Runtime/Core/Random/XoroShiroRandom.cs +3 -3
- package/Runtime/Tags/AttributeMetadataCache.cs +316 -9
- package/Runtime/Tags/CosmeticEffectData.cs +1 -1
- package/Runtime/Visuals/UIToolkit/MultiFileSelectorElement.cs +3 -3
- package/Tests/Editor/Helper/HelpersTests.cs +2 -2
- package/Tests/Editor/Helper/ReflectionHelpersTypedEditorTests.cs +87 -0
- package/Tests/Editor/Helper/ReflectionHelpersTypedEditorTests.cs.meta +11 -0
- package/Tests/Editor/Helper/SpriteHelpersTests.cs +1 -1
- package/Tests/Editor/PrefabCheckerReportTests.cs +3 -3
- package/Tests/Editor/Sprites/AnimationCopierFilterTests.cs +18 -12
- package/Tests/Editor/Sprites/AnimationCopierWindowTests.cs +8 -7
- package/Tests/Editor/Sprites/AnimationViewerWindowTests.cs +2 -1
- package/Tests/Editor/Sprites/ScriptableSpriteAtlasEditorTests.cs +6 -5
- package/Tests/Editor/Sprites/SpriteCropperAdditionalTests.cs +2 -1
- package/Tests/Editor/Sprites/SpriteCropperTests.cs +7 -6
- package/Tests/Editor/Sprites/SpritePivotAdjusterAdditionalTests.cs +2 -1
- package/Tests/Editor/Sprites/SpritePivotAdjusterTests.cs +4 -3
- package/Tests/Editor/Sprites/TextureResizerWizardTests.cs +10 -9
- package/Tests/Editor/Sprites/TextureSettingsApplierAPITests.cs +2 -1
- package/Tests/Editor/Tags/AttributeMetadataCacheTests.cs +192 -0
- package/Tests/Editor/Tags/AttributeMetadataCacheTests.cs.meta +11 -0
- package/Tests/Editor/Tags.meta +8 -0
- package/Tests/Runtime/Extensions/IListExtensionTests.cs +187 -1
- package/Tests/Runtime/Helper/ObjectsTests.cs +4 -4
- package/Tests/Runtime/Helper/ReflectionHelperCapabilityMatrixTests.cs +2923 -0
- package/Tests/Runtime/Helper/ReflectionHelperCapabilityMatrixTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/ReflectionHelperTests.cs +660 -0
- package/Tests/Runtime/Integrations/Reflex/RelationalComponentsReflexTests.cs +2 -2
- package/Tests/Runtime/Performance/IListSortingPerformanceTests.cs +346 -0
- package/Tests/Runtime/Performance/IListSortingPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +3 -0
- package/Tests/Runtime/Performance/ReflectionPerformanceTests.cs +1238 -0
- package/Tests/Runtime/Performance/ReflectionPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/RelationalComponentBenchmarkTests.cs +832 -0
- package/Tests/Runtime/Performance/RelationalComponentBenchmarkTests.cs.meta +11 -0
- package/Tests/Runtime/Random/FlurryBurstRandomTests.cs +12 -0
- package/Tests/Runtime/Random/FlurryBurstRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Random/PhotonSpinRandomTests.cs +12 -0
- package/Tests/Runtime/Random/PhotonSpinRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Random/RandomProtoSerializationTests.cs +14 -0
- package/Tests/Runtime/Random/RandomTestBase.cs +39 -4
- package/Tests/Runtime/Random/StormDropRandomTests.cs +12 -0
- package/Tests/Runtime/Random/StormDropRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Serialization/ProtoInterfaceResolutionEdgeTests.cs +2 -2
- package/Tests/Runtime/Serialization/ProtoRootRegistrationTests.cs +1 -1
- package/Tests/Runtime/Serialization/ProtoSerializeBehaviorTests.cs +1 -1
- package/Tests/Runtime/Tags/PeriodicEffectDefinitionSerializationTests.cs +2 -2
- package/package.json +1 -1
- package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs +0 -60
- package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs.meta +0 -3
|
@@ -17,6 +17,14 @@ namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
|
17
17
|
public int Compare(int x, int y) => x.CompareTo(y);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
private sealed class StableTupleComparer : IComparer<ValueTuple<int, int>>
|
|
21
|
+
{
|
|
22
|
+
public int Compare(ValueTuple<int, int> x, ValueTuple<int, int> y)
|
|
23
|
+
{
|
|
24
|
+
return x.Item1.CompareTo(y.Item1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
private readonly struct IntEqualityComparer : IEqualityComparer<int>
|
|
21
29
|
{
|
|
22
30
|
public bool Equals(int x, int y) => x == y;
|
|
@@ -135,7 +143,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
[Test]
|
|
138
|
-
public void
|
|
146
|
+
public void GhostSort()
|
|
139
147
|
{
|
|
140
148
|
for (int i = 0; i < NumTries; ++i)
|
|
141
149
|
{
|
|
@@ -153,6 +161,120 @@ namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
163
|
|
|
164
|
+
[Test]
|
|
165
|
+
public void MeteorSort()
|
|
166
|
+
{
|
|
167
|
+
for (int i = 0; i < NumTries; ++i)
|
|
168
|
+
{
|
|
169
|
+
int[] input = Enumerable
|
|
170
|
+
.Range(0, 100)
|
|
171
|
+
.Select(_ => PRNG.Instance.Next(int.MinValue, int.MaxValue))
|
|
172
|
+
.ToArray();
|
|
173
|
+
int[] conventionalSorted = input.ToArray();
|
|
174
|
+
Array.Sort(conventionalSorted);
|
|
175
|
+
|
|
176
|
+
int[] meteorSorted = input.ToArray();
|
|
177
|
+
meteorSorted.MeteorSort(new IntComparer());
|
|
178
|
+
Assert.That(conventionalSorted, Is.EqualTo(meteorSorted));
|
|
179
|
+
Assert.That(input.OrderBy(x => x), Is.EqualTo(meteorSorted));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[Test]
|
|
184
|
+
public void PatternDefeatingQuickSort()
|
|
185
|
+
{
|
|
186
|
+
for (int i = 0; i < NumTries; ++i)
|
|
187
|
+
{
|
|
188
|
+
int[] input = Enumerable
|
|
189
|
+
.Range(0, 100)
|
|
190
|
+
.Select(_ => PRNG.Instance.Next(int.MinValue, int.MaxValue))
|
|
191
|
+
.ToArray();
|
|
192
|
+
int[] conventionalSorted = input.ToArray();
|
|
193
|
+
Array.Sort(conventionalSorted);
|
|
194
|
+
|
|
195
|
+
int[] pdqSorted = input.ToArray();
|
|
196
|
+
pdqSorted.PatternDefeatingQuickSort(new IntComparer());
|
|
197
|
+
Assert.That(conventionalSorted, Is.EqualTo(pdqSorted));
|
|
198
|
+
Assert.That(input.OrderBy(x => x), Is.EqualTo(pdqSorted));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
[Test]
|
|
203
|
+
public void GrailSort()
|
|
204
|
+
{
|
|
205
|
+
for (int i = 0; i < NumTries; ++i)
|
|
206
|
+
{
|
|
207
|
+
int[] input = Enumerable
|
|
208
|
+
.Range(0, 100)
|
|
209
|
+
.Select(_ => PRNG.Instance.Next(int.MinValue, int.MaxValue))
|
|
210
|
+
.ToArray();
|
|
211
|
+
int[] conventionalSorted = input.ToArray();
|
|
212
|
+
Array.Sort(conventionalSorted);
|
|
213
|
+
|
|
214
|
+
int[] grailSorted = input.ToArray();
|
|
215
|
+
grailSorted.GrailSort(new IntComparer());
|
|
216
|
+
Assert.That(conventionalSorted, Is.EqualTo(grailSorted));
|
|
217
|
+
Assert.That(input.OrderBy(x => x), Is.EqualTo(grailSorted));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[Test]
|
|
222
|
+
public void PowerSort()
|
|
223
|
+
{
|
|
224
|
+
for (int i = 0; i < NumTries; ++i)
|
|
225
|
+
{
|
|
226
|
+
int[] input = Enumerable
|
|
227
|
+
.Range(0, 100)
|
|
228
|
+
.Select(_ => PRNG.Instance.Next(int.MinValue, int.MaxValue))
|
|
229
|
+
.ToArray();
|
|
230
|
+
int[] conventionalSorted = input.ToArray();
|
|
231
|
+
Array.Sort(conventionalSorted);
|
|
232
|
+
|
|
233
|
+
int[] powerSorted = input.ToArray();
|
|
234
|
+
powerSorted.PowerSort(new IntComparer());
|
|
235
|
+
Assert.That(conventionalSorted, Is.EqualTo(powerSorted));
|
|
236
|
+
Assert.That(input.OrderBy(x => x), Is.EqualTo(powerSorted));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
[Test]
|
|
241
|
+
public void GrailSortIsStable()
|
|
242
|
+
{
|
|
243
|
+
ValueTuple<int, int>[] input = Enumerable
|
|
244
|
+
.Range(0, 100)
|
|
245
|
+
.Select(i => ValueTuple.Create(i / 5, i))
|
|
246
|
+
.ToArray();
|
|
247
|
+
ValueTuple<int, int>[] grailSorted = input.ToArray();
|
|
248
|
+
grailSorted.GrailSort(new StableTupleComparer());
|
|
249
|
+
|
|
250
|
+
for (int i = 1; i < grailSorted.Length; ++i)
|
|
251
|
+
{
|
|
252
|
+
if (grailSorted[i - 1].Item1 == grailSorted[i].Item1)
|
|
253
|
+
{
|
|
254
|
+
Assert.That(grailSorted[i - 1].Item2, Is.LessThan(grailSorted[i].Item2));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
[Test]
|
|
260
|
+
public void PowerSortIsStable()
|
|
261
|
+
{
|
|
262
|
+
ValueTuple<int, int>[] input = Enumerable
|
|
263
|
+
.Range(0, 100)
|
|
264
|
+
.Select(i => ValueTuple.Create(i / 4, i))
|
|
265
|
+
.ToArray();
|
|
266
|
+
ValueTuple<int, int>[] powerSorted = input.ToArray();
|
|
267
|
+
powerSorted.PowerSort(new StableTupleComparer());
|
|
268
|
+
|
|
269
|
+
for (int i = 1; i < powerSorted.Length; ++i)
|
|
270
|
+
{
|
|
271
|
+
if (powerSorted[i - 1].Item1 == powerSorted[i].Item1)
|
|
272
|
+
{
|
|
273
|
+
Assert.That(powerSorted[i - 1].Item2, Is.LessThan(powerSorted[i].Item2));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
156
278
|
[Test]
|
|
157
279
|
public void SortDefaultAlgorithm()
|
|
158
280
|
{
|
|
@@ -731,6 +853,70 @@ namespace WallstopStudios.UnityHelpers.Tests.Extensions
|
|
|
731
853
|
Assert.That(single, Is.EqualTo(new[] { 42 }));
|
|
732
854
|
}
|
|
733
855
|
|
|
856
|
+
[Test]
|
|
857
|
+
public void PatternDefeatingQuickSortEmptyList()
|
|
858
|
+
{
|
|
859
|
+
int[] empty = Array.Empty<int>();
|
|
860
|
+
empty.PatternDefeatingQuickSort(new IntComparer());
|
|
861
|
+
Assert.That(empty, Is.Empty);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
[Test]
|
|
865
|
+
public void PatternDefeatingQuickSortSingleElement()
|
|
866
|
+
{
|
|
867
|
+
int[] single = { 42 };
|
|
868
|
+
single.PatternDefeatingQuickSort(new IntComparer());
|
|
869
|
+
Assert.That(single, Is.EqualTo(new[] { 42 }));
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
[Test]
|
|
873
|
+
public void GrailSortEmptyList()
|
|
874
|
+
{
|
|
875
|
+
int[] empty = Array.Empty<int>();
|
|
876
|
+
empty.GrailSort(new IntComparer());
|
|
877
|
+
Assert.That(empty, Is.Empty);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
[Test]
|
|
881
|
+
public void GrailSortSingleElement()
|
|
882
|
+
{
|
|
883
|
+
int[] single = { 42 };
|
|
884
|
+
single.GrailSort(new IntComparer());
|
|
885
|
+
Assert.That(single, Is.EqualTo(new[] { 42 }));
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
[Test]
|
|
889
|
+
public void PowerSortEmptyList()
|
|
890
|
+
{
|
|
891
|
+
int[] empty = Array.Empty<int>();
|
|
892
|
+
empty.PowerSort(new IntComparer());
|
|
893
|
+
Assert.That(empty, Is.Empty);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
[Test]
|
|
897
|
+
public void PowerSortSingleElement()
|
|
898
|
+
{
|
|
899
|
+
int[] single = { 42 };
|
|
900
|
+
single.PowerSort(new IntComparer());
|
|
901
|
+
Assert.That(single, Is.EqualTo(new[] { 42 }));
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
[Test]
|
|
905
|
+
public void MeteorSortEmptyList()
|
|
906
|
+
{
|
|
907
|
+
int[] empty = Array.Empty<int>();
|
|
908
|
+
empty.MeteorSort(new IntComparer());
|
|
909
|
+
Assert.That(empty, Is.Empty);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
[Test]
|
|
913
|
+
public void MeteorSortSingleElement()
|
|
914
|
+
{
|
|
915
|
+
int[] single = { 42 };
|
|
916
|
+
single.MeteorSort(new IntComparer());
|
|
917
|
+
Assert.That(single, Is.EqualTo(new[] { 42 }));
|
|
918
|
+
}
|
|
919
|
+
|
|
734
920
|
[Test]
|
|
735
921
|
public void CombinedOperationsShuffleThenSort()
|
|
736
922
|
{
|
|
@@ -293,7 +293,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Helper
|
|
|
293
293
|
CustomClass[] array = { a, b, c };
|
|
294
294
|
ReadOnlySpan<CustomClass> span = array;
|
|
295
295
|
|
|
296
|
-
int spanHash = Objects.
|
|
296
|
+
int spanHash = Objects.SpanHashCode(span);
|
|
297
297
|
int variadicHash = Objects.HashCode(a, b, c);
|
|
298
298
|
|
|
299
299
|
Assert.AreEqual(variadicHash, spanHash);
|
|
@@ -343,8 +343,8 @@ namespace WallstopStudios.UnityHelpers.Tests.Helper
|
|
|
343
343
|
CustomEnumerable ascending = new(1, 2, 3);
|
|
344
344
|
CustomEnumerable descending = new(3, 2, 1);
|
|
345
345
|
|
|
346
|
-
int ascHash = Objects.EnumerableHashCode
|
|
347
|
-
int descHash = Objects.EnumerableHashCode
|
|
346
|
+
int ascHash = Objects.EnumerableHashCode(ascending);
|
|
347
|
+
int descHash = Objects.EnumerableHashCode(descending);
|
|
348
348
|
|
|
349
349
|
Assert.AreNotEqual(ascHash, descHash);
|
|
350
350
|
}
|
|
@@ -354,7 +354,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Helper
|
|
|
354
354
|
{
|
|
355
355
|
DisposableEnumerable enumerable = new(1, 2, 3);
|
|
356
356
|
|
|
357
|
-
int result = Objects.EnumerableHashCode
|
|
357
|
+
int result = Objects.EnumerableHashCode(enumerable);
|
|
358
358
|
|
|
359
359
|
Assert.AreNotEqual(0, result);
|
|
360
360
|
Assert.IsTrue(enumerable.LastEnumerator.WasDisposed);
|