com.valectric.mooserunner 2.1.17 → 2.1.19

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.
@@ -21,6 +21,7 @@ namespace MooseRunner.Internal.Tests
21
21
  [OneTimeSetUp]
22
22
  public async Task OneTimeSetupMethod(CancellationToken ct)
23
23
  {
24
+ MooseRunnerSampleVersionCheck.EnsureSingleVersion();
24
25
  Debug.Log("[OneTimeSetUp] OneTimeSetUp started - 5 second delay");
25
26
  Debug.Log("[OneTimeSetUp] Click STOP during OneTimeSetUp to test cancellation");
26
27
  await Task.Delay(5000, ct);
@@ -27,6 +27,7 @@ namespace MooseRunner.Internal.Tests
27
27
  [OneTimeSetUp]
28
28
  public async Task SetUpOnce()
29
29
  {
30
+ MooseRunnerSampleVersionCheck.EnsureSingleVersion();
30
31
  await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
31
32
  }
32
33
 
@@ -27,6 +27,7 @@ namespace MooseRunner.Internal.Tests
27
27
  [OneTimeSetUp]
28
28
  public async Task SetUpOnce()
29
29
  {
30
+ MooseRunnerSampleVersionCheck.EnsureSingleVersion();
30
31
  await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("RealUseCaseScene");
31
32
  }
32
33
 
@@ -0,0 +1,57 @@
1
+ using System;
2
+ using System.IO;
3
+ using System.Linq;
4
+ using UnityEngine;
5
+
6
+ namespace MooseRunner.Internal.Tests
7
+ {
8
+ /// <summary>
9
+ /// Detects duplicate MooseRunner sample-version folders in Assets/Samples/.
10
+ /// Unity's UPM Sample import creates a new <c>Assets/Samples/MooseRunner/&lt;version&gt;/...</c>
11
+ /// folder on every upgrade and never deletes the previous one. The duplicate .cs files
12
+ /// share class FQNs (e.g. <c>MooseRunner.Internal.Tests.Enemy</c>) and stable .meta GUIDs,
13
+ /// which produces a "is not derived from MonoBehaviour or ScriptableObject!" runtime
14
+ /// error when prefabs instantiate. Called from each sample test's OneTimeSetUp so the
15
+ /// check fires only when the customer actually uses the samples.
16
+ /// </summary>
17
+ public static class MooseRunnerSampleVersionCheck
18
+ {
19
+ private static bool _alreadyChecked;
20
+ private const string SamplesRoot = "Assets/Samples/MooseRunner";
21
+
22
+ /// <summary>
23
+ /// Throws <see cref="InvalidOperationException"/> if multiple MooseRunner sample-version
24
+ /// folders are present. First call performs the scan; subsequent calls within the same
25
+ /// domain are no-ops (the flag resets on domain reload, which is fine — the check is
26
+ /// idempotent and cheap).
27
+ /// </summary>
28
+ public static void EnsureSingleVersion()
29
+ {
30
+ if (_alreadyChecked) return;
31
+ _alreadyChecked = true;
32
+
33
+ if (!Directory.Exists(SamplesRoot)) return;
34
+
35
+ var versionDirs = Directory.GetDirectories(SamplesRoot);
36
+ if (versionDirs.Length <= 1) return;
37
+
38
+ var sortedFolders = versionDirs
39
+ .Select(Path.GetFileName)
40
+ .OrderBy(n => n)
41
+ .Select(n => " " + SamplesRoot + "/" + n);
42
+
43
+ string msg =
44
+ "Multiple MooseRunner sample versions detected. Unity's UPM 'Reimport Sample' " +
45
+ "creates a new versioned folder on every package upgrade and never deletes the " +
46
+ "previous one. Duplicate .cs files with the same class FQN and stable .meta GUIDs " +
47
+ "produce the runtime error \"... is not derived from MonoBehaviour or ScriptableObject!\" " +
48
+ "when prefabs instantiate.\n" +
49
+ "\n" +
50
+ "Found:\n" + string.Join("\n", sortedFolders) + "\n" +
51
+ "\n" +
52
+ "Fix: delete all but the newest folder under Assets/Samples/MooseRunner/, then re-run.";
53
+ Debug.LogError(msg);
54
+ throw new InvalidOperationException(msg);
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: fb03d23dca7f786428fa1f8e5887bf4b
@@ -21,6 +21,7 @@ namespace MooseRunner.Internal.Tests
21
21
  [OneTimeSetUp]
22
22
  public async Task SetUpOnce()
23
23
  {
24
+ MooseRunnerSampleVersionCheck.EnsureSingleVersion();
24
25
  await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
25
26
  }
26
27
 
@@ -29,6 +29,7 @@ namespace MooseRunner.Internal.Tests
29
29
  [OneTimeSetUp]
30
30
  public new async Task SetUpOnce()
31
31
  {
32
+ MooseRunnerSampleVersionCheck.EnsureSingleVersion();
32
33
  await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
33
34
  }
34
35
 
@@ -22,6 +22,7 @@ namespace MooseRunner.Internal.Tests
22
22
  [OneTimeSetUp]
23
23
  public async Task SetUpOnce()
24
24
  {
25
+ MooseRunnerSampleVersionCheck.EnsureSingleVersion();
25
26
  await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
26
27
  }
27
28
 
@@ -27,6 +27,7 @@ namespace MooseRunner.Internal.Tests
27
27
  [OneTimeSetUp]
28
28
  public void OneTimeSetUpMethod()
29
29
  {
30
+ MooseRunnerSampleVersionCheck.EnsureSingleVersion();
30
31
  // OneTimeSetUp should get a fresh instance, so _instanceId should be 99 (default)
31
32
  Assert.AreEqual(99, _instanceId, "OneTimeSetUp should start with default _instanceId = 99 (fresh instance)");
32
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.valectric.mooserunner",
3
- "version": "2.1.17",
3
+ "version": "2.1.19",
4
4
  "displayName": "MooseRunner",
5
5
  "description": "MooseRunner boosts PlayMode testing with Hot Reload, MCP for AIs, timescale control, and Task support. It enables rapid iteration, auto test reruns, full documentation and dedicated support.",
6
6
  "unity": "6000.2",