com.wallstop-studios.dxmessaging 2.0.0-rc17 → 2.0.0-rc18

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.
@@ -0,0 +1,33 @@
1
+ fileFormatVersion: 2
2
+ guid: 8c1cadaf86b083c49aac429e53fa3008
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 1
13
+ platformData:
14
+ - first:
15
+ Any:
16
+ second:
17
+ enabled: 0
18
+ settings: {}
19
+ - first:
20
+ Editor: Editor
21
+ second:
22
+ enabled: 1
23
+ settings:
24
+ DefaultValueInitialized: true
25
+ - first:
26
+ Windows Store Apps: WindowsStoreApps
27
+ second:
28
+ enabled: 0
29
+ settings:
30
+ CPU: AnyCPU
31
+ userData:
32
+ assetBundleName:
33
+ assetBundleVariant:
@@ -35,10 +35,13 @@ namespace DxMessaging.Editor
35
35
  "Microsoft.CodeAnalysis.dll",
36
36
  "Microsoft.CodeAnalysis.CSharp.dll",
37
37
  "System.Reflection.Metadata.dll",
38
+ "System.Runtime.CompilerServices.Unsafe.dll",
38
39
  };
39
40
 
40
41
  private static readonly string LibraryArgument = $"-a:\"{LibraryPathRelative}\"";
41
42
 
43
+ private static readonly HashSet<string> DllNames = new(StringComparer.OrdinalIgnoreCase);
44
+
42
45
  static SetupCscRsp()
43
46
  {
44
47
  EditorApplication.delayCall += EnsureDLLsExistInAssets;
@@ -47,21 +50,26 @@ namespace DxMessaging.Editor
47
50
 
48
51
  private static void EnsureDLLsExistInAssets()
49
52
  {
50
- HashSet<string> dllNames = new();
53
+ DllNames.Clear();
51
54
  foreach (
52
55
  string dllGuid in AssetDatabase.FindAssets("t:DefaultAsset", new[] { "Assets" })
53
56
  )
54
57
  {
55
58
  string dllPath = AssetDatabase.GUIDToAssetPath(dllGuid);
56
- if (!dllPath.EndsWith(".dll"))
59
+ if (!dllPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
57
60
  {
58
61
  continue;
59
62
  }
60
63
 
61
- if (!dllPath.Contains("Assets/Plugins/WallstopStudios.DxMessaging"))
64
+ if (
65
+ !dllPath.Contains(
66
+ "Assets/Plugins/WallstopStudios.DxMessaging",
67
+ StringComparison.OrdinalIgnoreCase
68
+ )
69
+ )
62
70
  {
63
71
  string dllName = Path.GetFileName(dllPath);
64
- dllNames.Add(dllName);
72
+ DllNames.Add(dllName);
65
73
  }
66
74
  }
67
75
 
@@ -70,7 +78,7 @@ namespace DxMessaging.Editor
70
78
  bool anyFound = false;
71
79
  foreach (
72
80
  string requiredDllName in RequiredDllNames.Where(dllName =>
73
- !dllNames.Contains(dllName)
81
+ !DllNames.Contains(dllName)
74
82
  )
75
83
  )
76
84
  {
@@ -160,12 +168,12 @@ namespace DxMessaging.Editor
160
168
  }
161
169
 
162
170
  string rspContent = File.ReadAllText(RspFilePath);
163
- if (rspContent.Contains(LibraryArgument))
171
+ if (rspContent.Contains(LibraryArgument, StringComparison.OrdinalIgnoreCase))
164
172
  {
165
173
  return;
166
174
  }
167
175
 
168
- File.AppendAllText(RspFilePath, $"{LibraryArgument}\n");
176
+ File.AppendAllText(RspFilePath, $"{LibraryArgument}{Environment.NewLine}");
169
177
  AssetDatabase.ImportAsset("csc.rsp");
170
178
  Debug.Log("Updated csc.rsp.");
171
179
  }
package/README.md CHANGED
@@ -26,26 +26,23 @@ Check out the latest [Releases](https://github.com/wallstop/DxMessaging/releases
26
26
  4. Add an entry for a new "Scoped Registry"
27
27
  - Name: `NPM`
28
28
  - URL: `https://registry.npmjs.org`
29
- - Scope(s): `com.wallstop-studios.dxmessaging` *and* `com.wallstop-studios.unity-helpers`
29
+ - Scope(s): `com.wallstop-studios.dxmessaging`
30
30
  5. Resolve the latest `DxMessaging`
31
31
 
32
32
  ## From Source
33
33
  Grab a copy of this repo (either `git clone` both [this repo](https://github.com/wallstop/DxMessaging) *and* [Unity Helpers](https://github.com/wallstop/unity-helpers) or [download a zip of the source](https://github.com/wallstop/DxMessaging/archive/refs/heads/master.zip) and [Unity Helper's source](https://github.com/wallstop/unity-helpers/archive/refs/heads/main.zip)) and copy the contents to your project's `Assets` folder.
34
34
 
35
- # Dependencies
36
- This project has a dependency on my [`Unity Helpers`](https://github.com/wallstop/unity-helpers) project, which contains the `System.Runtime.CompilerServices.Unsafe.dll`, which is used for some speed hacks in DxMessaging directly. Unity Helpers bundles a few (small) dependencies, including protobuf. If you don't want these dependencies, or if they conflict in some way, you can either include a copy of the `System.Runtime.CompilerServices.Unsafe.dll` yourself without relying on UnityHelpers, or manually download and include the Unity Helpers project and delete anything that conflicts with your project. Or, manually download this project without UnityHelpers. The choice is yours.
37
-
38
35
  # Benchmarks
39
36
  DxMessaging is currently roughly on-par with than Unity's built in messaging solution (when running in Unity). [Source](./Tests/Runtime/Benchmarks/PerformanceTests.cs). However, it is allocation-free and can be used in hot paths.
40
37
 
41
38
  | Message Tech | Operations / Second | Allocations? |
42
39
  | ------------ | ------------------- | ------------ |
43
- | Unity | 2,493,950 | Yes |
44
- | DxMessaging (GameObject) - Normal | 2,075,850 | No |
45
- | DxMessaging (Component) - Normal | 2,072,550 | No |
46
- | DxMessaging (GameObject) - No-Copy | 2,159,400 | No |
47
- | DxMessaging (Component) - No-Copy | 2,163,800 | No |
48
- | DxMessaging (Untargeted) - No-Copy | 3,086,450 | No |
40
+ | Unity | 2,621,200 | Yes |
41
+ | DxMessaging (GameObject) - Normal | 2,048,600 | No |
42
+ | DxMessaging (Component) - Normal | 2,054,600 | No |
43
+ | DxMessaging (GameObject) - No-Copy | 2,137,800 | No |
44
+ | DxMessaging (Component) - No-Copy | 2,136,400 | No |
45
+ | DxMessaging (Untargeted) - No-Copy | 3,028,400 | No |
49
46
 
50
47
  # Functionality
51
48
  While not as fast, DxMessaging offers *additional functionality* as compared to Unity's messaging solution.
@@ -17,7 +17,7 @@
17
17
 
18
18
  public sealed class PerformanceTests : MessagingTestBase
19
19
  {
20
- private const int NumInvocationsPerIteration = 250;
20
+ private const int NumInvocationsPerIteration = 1_000;
21
21
 
22
22
  protected override bool MessagingDebugEnabled => false;
23
23
 
@@ -0,0 +1,69 @@
1
+ namespace DxMessaging.Tests.Runtime.Core
2
+ {
3
+ using System.Collections;
4
+ using DxMessaging.Core.Extensions;
5
+ using NUnit.Framework;
6
+ using Scripts.Components;
7
+ using Scripts.Messages;
8
+ using UnityEngine;
9
+ using UnityEngine.TestTools;
10
+
11
+ public sealed class EnablementTests : MessagingTestBase
12
+ {
13
+ [UnityTest]
14
+ public IEnumerator StartsDisabled()
15
+ {
16
+ GameObject prefab = new("Prefab", typeof(SimpleMessageAwareComponent));
17
+ _spawned.Add(prefab);
18
+ SimpleMessageAwareComponent prefabMessaging =
19
+ prefab.GetComponent<SimpleMessageAwareComponent>();
20
+ prefabMessaging.enabled = false;
21
+
22
+ GameObject copy = Object.Instantiate(prefab);
23
+ _spawned.Add(copy);
24
+ SimpleMessageAwareComponent spawnedMessaging =
25
+ copy.GetComponent<SimpleMessageAwareComponent>();
26
+ Assert.IsFalse(spawnedMessaging.enabled);
27
+ int copyCount = 0;
28
+ spawnedMessaging.untargetedHandler += () => copyCount++;
29
+
30
+ SimpleUntargetedMessage untargeted = new();
31
+ untargeted.EmitUntargeted();
32
+ Assert.AreEqual(0, copyCount);
33
+
34
+ spawnedMessaging.enabled = true;
35
+ untargeted.EmitUntargeted();
36
+ Assert.AreEqual(1, copyCount);
37
+ yield break;
38
+ }
39
+
40
+ [UnityTest]
41
+ public IEnumerator StartsEnabled()
42
+ {
43
+ GameObject prefab = new("Prefab", typeof(SimpleMessageAwareComponent));
44
+ _spawned.Add(prefab);
45
+ SimpleMessageAwareComponent prefabMessaging =
46
+ prefab.GetComponent<SimpleMessageAwareComponent>();
47
+
48
+ int count = 0;
49
+ prefabMessaging.untargetedHandler += () => count++;
50
+
51
+ SimpleUntargetedMessage untargeted = new();
52
+ untargeted.EmitUntargeted();
53
+ Assert.AreEqual(1, count);
54
+
55
+ prefabMessaging.enabled = false;
56
+ untargeted.EmitUntargeted();
57
+ Assert.AreEqual(1, count);
58
+
59
+ prefabMessaging.enabled = true;
60
+ untargeted.EmitUntargeted();
61
+ Assert.AreEqual(2, count);
62
+
63
+ Object.Destroy(prefabMessaging);
64
+ yield return null;
65
+ untargeted.EmitUntargeted();
66
+ Assert.AreEqual(2, count);
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: eea2922068114db1a00375d95322a755
3
+ timeCreated: 1744481637
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.dxmessaging",
3
- "version": "2.0.0-rc17",
3
+ "version": "2.0.0-rc18",
4
4
  "displayName": "DxMessaging",
5
5
  "description": "Synchronous Event Bus for Unity",
6
6
  "unity": "2021.3",
7
- "dependencies": {
8
- "com.wallstop-studios.unity-helpers" : "2.0.0-rc58"
9
- },
7
+ "dependencies": {},
10
8
  "keywords": [
11
9
  "messaging",
12
10
  "message",