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

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.
Files changed (33) hide show
  1. package/.config/dotnet-tools.json +10 -0
  2. package/.editorconfig +184 -0
  3. package/.pre-commit-config.yaml +22 -0
  4. package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  5. package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.pdb.meta +7 -0
  6. package/Editor/SetupCscRsp.cs +24 -7
  7. package/README.md +7 -17
  8. package/Runtime/Core/Attributes/DxBroadcastMessageAttribute.cs +5 -1
  9. package/Runtime/Core/Attributes/DxTargetedMessageAttribute.cs +5 -1
  10. package/Runtime/Core/Attributes/DxUntargetedMessageAttribute.cs +5 -1
  11. package/Runtime/Core/IMessage.cs +13 -0
  12. package/Runtime/Core/InstanceId.cs +6 -16
  13. package/Runtime/Core/MessageBus/MessageBus.cs +1751 -828
  14. package/Runtime/Core/MessageHandler.cs +408 -292
  15. package/Runtime/Unity/MessageAwareComponent.cs +0 -1
  16. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +445 -0
  17. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs.meta +3 -0
  18. package/Tests/Runtime/Benchmarks/PerformanceTests.cs +41 -26
  19. package/Tests/Runtime/Scripts/Components/GenericMessageAwareComponent.cs +19 -0
  20. package/Tests/Runtime/Scripts/Components/GenericMessageAwareComponent.cs.meta +3 -0
  21. package/Tests/Runtime/Scripts/Messages/GenericUntargetedMessage.cs +7 -0
  22. package/Tests/Runtime/Scripts/Messages/GenericUntargetedMessage.cs.meta +3 -0
  23. package/package.json +2 -2
  24. package/Runtime/Core/Attributes/DxAutoMessageTypeAttribute.cs +0 -7
  25. package/Runtime/Core/Attributes/DxAutoMessageTypeAttribute.cs.meta +0 -3
  26. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoMessageTypeGenerator.cs +0 -92
  27. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoMessageTypeGenerator.cs.meta +0 -11
  28. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxBroadcastMessageGenerator.cs +0 -94
  29. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxBroadcastMessageGenerator.cs.meta +0 -3
  30. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxTargetedMessageGenerator.cs +0 -94
  31. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxTargetedMessageGenerator.cs.meta +0 -3
  32. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxUntargetedMessageGenerator.cs +0 -94
  33. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxUntargetedMessageGenerator.cs.meta +0 -3
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 1,
3
+ "isRoot": true,
4
+ "tools": {
5
+ "CSharpier": {
6
+ "version": "0.30.6",
7
+ "commands": ["dotnet-csharpier"]
8
+ }
9
+ }
10
+ }
package/.editorconfig ADDED
@@ -0,0 +1,184 @@
1
+
2
+ [*]
3
+ charset = utf-8-bom
4
+ end_of_line = crlf
5
+ trim_trailing_whitespace = false
6
+ insert_final_newline = false
7
+ indent_style = space
8
+ indent_size = 4
9
+
10
+ # Microsoft .NET properties
11
+ csharp_new_line_before_members_in_object_initializers = false
12
+ csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
13
+ csharp_prefer_braces = true:suggestion
14
+ csharp_style_prefer_utf8_string_literals = true:suggestion
15
+ csharp_style_var_elsewhere = false:suggestion
16
+ csharp_style_var_for_built_in_types = false:suggestion
17
+ csharp_style_var_when_type_is_apparent = false:suggestion
18
+ csharp_using_directive_placement = inside_namespace:silent
19
+ dotnet_naming_rule.event_rule.import_to_resharper = True
20
+ dotnet_naming_rule.event_rule.resharper_description = Events
21
+ dotnet_naming_rule.event_rule.resharper_guid = 0c4c6401-2a1f-4db1-a21f-562f51542cf8
22
+ dotnet_naming_rule.event_rule.severity = warning
23
+ dotnet_naming_rule.event_rule.style = on_upper_camel_case_style
24
+ dotnet_naming_rule.event_rule.symbols = event_symbols
25
+ dotnet_naming_rule.interfaces_rule.import_to_resharper = True
26
+ dotnet_naming_rule.interfaces_rule.resharper_description = Interfaces
27
+ dotnet_naming_rule.interfaces_rule.resharper_guid = a7a3339e-4e89-4319-9735-a9dc4cb74cc7
28
+ dotnet_naming_rule.interfaces_rule.severity = warning
29
+ dotnet_naming_rule.interfaces_rule.style = i_upper_camel_case_style
30
+ dotnet_naming_rule.interfaces_rule.symbols = interfaces_symbols
31
+ dotnet_naming_rule.local_constants_rule.import_to_resharper = True
32
+ dotnet_naming_rule.local_constants_rule.resharper_description = Local constants
33
+ dotnet_naming_rule.local_constants_rule.resharper_guid = a4f433b8-abcd-4e55-a08f-82e78cef0f0c
34
+ dotnet_naming_rule.local_constants_rule.resharper_style = AaBb, aaBb
35
+ dotnet_naming_rule.local_constants_rule.severity = warning
36
+ dotnet_naming_rule.local_constants_rule.style = upper_camel_case_style
37
+ dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols
38
+ dotnet_naming_rule.public_fields_override_rule.import_to_resharper = False
39
+ dotnet_naming_rule.public_fields_override_rule.severity = warning
40
+ dotnet_naming_rule.public_fields_override_rule.style = upper_camel_case_style
41
+ dotnet_naming_rule.public_fields_override_rule.symbols = public_fields_override_symbols
42
+ dotnet_naming_rule.public_fields_override_rule_1.import_to_resharper = False
43
+ dotnet_naming_rule.public_fields_override_rule_1.severity = warning
44
+ dotnet_naming_rule.public_fields_override_rule_1.style = upper_camel_case_style
45
+ dotnet_naming_rule.public_fields_override_rule_1.symbols = public_fields_override_symbols_1
46
+ dotnet_naming_rule.public_fields_rule.import_to_resharper = True
47
+ dotnet_naming_rule.public_fields_rule.resharper_description = Instance fields (not private)
48
+ dotnet_naming_rule.public_fields_rule.resharper_guid = 53eecf85-d821-40e8-ac97-fdb734542b84
49
+ dotnet_naming_rule.public_fields_rule.severity = warning
50
+ dotnet_naming_rule.public_fields_rule.style = lower_camel_case_style
51
+ dotnet_naming_rule.public_fields_rule.symbols = public_fields_symbols
52
+ dotnet_naming_rule.public_static_fields_rule.import_to_resharper = True
53
+ dotnet_naming_rule.public_static_fields_rule.resharper_description = Static fields (not private)
54
+ dotnet_naming_rule.public_static_fields_rule.resharper_guid = 70345118-4b40-4ece-937c-bbeb7a0b2e70
55
+ dotnet_naming_rule.public_static_fields_rule.severity = warning
56
+ dotnet_naming_rule.public_static_fields_rule.style = upper_camel_case_style
57
+ dotnet_naming_rule.public_static_fields_rule.symbols = public_static_fields_symbols
58
+ dotnet_naming_rule.type_parameters_rule.import_to_resharper = True
59
+ dotnet_naming_rule.type_parameters_rule.resharper_description = Type parameters
60
+ dotnet_naming_rule.type_parameters_rule.resharper_guid = 2c62818f-621b-4425-adc9-78611099bfcb
61
+ dotnet_naming_rule.type_parameters_rule.severity = warning
62
+ dotnet_naming_rule.type_parameters_rule.style = t_upper_camel_case_style
63
+ dotnet_naming_rule.type_parameters_rule.symbols = type_parameters_symbols
64
+ dotnet_naming_rule.unity_serialized_field_rule.import_to_resharper = True
65
+ dotnet_naming_rule.unity_serialized_field_rule.resharper_description = Unity serialized field
66
+ dotnet_naming_rule.unity_serialized_field_rule.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef
67
+ dotnet_naming_rule.unity_serialized_field_rule.severity = none
68
+ dotnet_naming_rule.unity_serialized_field_rule.style = lower_camel_case_style
69
+ dotnet_naming_rule.unity_serialized_field_rule.symbols = unity_serialized_field_symbols
70
+ dotnet_naming_style.i_upper_camel_case_style.capitalization = pascal_case
71
+ dotnet_naming_style.i_upper_camel_case_style.required_prefix = I
72
+ dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
73
+ dotnet_naming_style.on_upper_camel_case_style.capitalization = pascal_case
74
+ dotnet_naming_style.on_upper_camel_case_style.required_prefix = On
75
+ dotnet_naming_style.t_upper_camel_case_style.capitalization = pascal_case
76
+ dotnet_naming_style.t_upper_camel_case_style.required_prefix = T
77
+ dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case
78
+ dotnet_naming_symbols.event_symbols.applicable_accessibilities = *
79
+ dotnet_naming_symbols.event_symbols.applicable_kinds = event
80
+ dotnet_naming_symbols.event_symbols.resharper_applicable_kinds = event
81
+ dotnet_naming_symbols.event_symbols.resharper_required_modifiers = any
82
+ dotnet_naming_symbols.interfaces_symbols.applicable_accessibilities = *
83
+ dotnet_naming_symbols.interfaces_symbols.applicable_kinds = interface
84
+ dotnet_naming_symbols.interfaces_symbols.resharper_applicable_kinds = interface
85
+ dotnet_naming_symbols.interfaces_symbols.resharper_required_modifiers = any
86
+ dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = *
87
+ dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local
88
+ dotnet_naming_symbols.local_constants_symbols.required_modifiers = const
89
+ dotnet_naming_symbols.local_constants_symbols.resharper_applicable_kinds = local_constant
90
+ dotnet_naming_symbols.local_constants_symbols.resharper_required_modifiers = any
91
+ dotnet_naming_symbols.public_fields_override_symbols.applicable_accessibilities = public
92
+ dotnet_naming_symbols.public_fields_override_symbols.applicable_kinds = field
93
+ dotnet_naming_symbols.public_fields_override_symbols.required_modifiers = const
94
+ dotnet_naming_symbols.public_fields_override_symbols_1.applicable_accessibilities = public
95
+ dotnet_naming_symbols.public_fields_override_symbols_1.applicable_kinds = field
96
+ dotnet_naming_symbols.public_fields_override_symbols_1.required_modifiers = readonly,static
97
+ dotnet_naming_symbols.public_fields_symbols.applicable_accessibilities = public
98
+ dotnet_naming_symbols.public_fields_symbols.applicable_kinds = field
99
+ dotnet_naming_symbols.public_fields_symbols.resharper_applicable_kinds = field,readonly_field
100
+ dotnet_naming_symbols.public_fields_symbols.resharper_required_modifiers = instance
101
+ dotnet_naming_symbols.public_static_fields_symbols.applicable_accessibilities = public
102
+ dotnet_naming_symbols.public_static_fields_symbols.applicable_kinds = field
103
+ dotnet_naming_symbols.public_static_fields_symbols.required_modifiers = static
104
+ dotnet_naming_symbols.public_static_fields_symbols.resharper_applicable_kinds = field
105
+ dotnet_naming_symbols.public_static_fields_symbols.resharper_required_modifiers = static
106
+ dotnet_naming_symbols.type_parameters_symbols.applicable_accessibilities = *
107
+ dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter
108
+ dotnet_naming_symbols.type_parameters_symbols.resharper_applicable_kinds = type_parameter
109
+ dotnet_naming_symbols.type_parameters_symbols.resharper_required_modifiers = any
110
+ dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
111
+ dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
112
+ dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
113
+ dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance
114
+ dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
115
+ dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
116
+ dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
117
+ dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
118
+ dotnet_style_predefined_type_for_member_access = true:suggestion
119
+ dotnet_style_qualification_for_event = false:suggestion
120
+ dotnet_style_qualification_for_field = false:suggestion
121
+ dotnet_style_qualification_for_method = false:suggestion
122
+ dotnet_style_qualification_for_property = false:suggestion
123
+ dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
124
+
125
+ # ReSharper properties
126
+ resharper_autodetect_indent_settings = true
127
+ resharper_braces_redundant = true
128
+ resharper_csharp_wrap_lines = false
129
+ resharper_formatter_off_tag = @formatter:off
130
+ resharper_formatter_on_tag = @formatter:on
131
+ resharper_formatter_tags_enabled = true
132
+ resharper_indent_preprocessor_directives = normal
133
+ resharper_keep_existing_attribute_arrangement = true
134
+ resharper_place_attribute_on_same_line = false
135
+ resharper_show_autodetect_configure_formatting_tip = false
136
+ resharper_use_indent_from_vs = false
137
+
138
+ # ReSharper inspection severities
139
+ resharper_arrange_redundant_parentheses_highlighting = hint
140
+ resharper_arrange_this_qualifier_highlighting = hint
141
+ resharper_arrange_trailing_comma_in_multiline_lists_highlighting = none
142
+ resharper_arrange_type_member_modifiers_highlighting = hint
143
+ resharper_arrange_type_modifiers_highlighting = hint
144
+ resharper_built_in_type_reference_style_for_member_access_highlighting = hint
145
+ resharper_built_in_type_reference_style_highlighting = hint
146
+ resharper_mvc_action_not_resolved_highlighting = warning
147
+ resharper_mvc_area_not_resolved_highlighting = warning
148
+ resharper_mvc_controller_not_resolved_highlighting = warning
149
+ resharper_mvc_masterpage_not_resolved_highlighting = warning
150
+ resharper_mvc_partial_view_not_resolved_highlighting = warning
151
+ resharper_mvc_template_not_resolved_highlighting = warning
152
+ resharper_mvc_view_component_not_resolved_highlighting = warning
153
+ resharper_mvc_view_component_view_not_resolved_highlighting = warning
154
+ resharper_mvc_view_not_resolved_highlighting = warning
155
+ resharper_prefer_concrete_value_over_default_highlighting = none
156
+ resharper_razor_assembly_not_resolved_highlighting = warning
157
+ resharper_redundant_base_qualifier_highlighting = warning
158
+ resharper_suggest_var_or_type_built_in_types_highlighting = hint
159
+ resharper_suggest_var_or_type_elsewhere_highlighting = hint
160
+ resharper_suggest_var_or_type_simple_types_highlighting = hint
161
+ resharper_web_config_module_not_resolved_highlighting = warning
162
+ resharper_web_config_type_not_resolved_highlighting = warning
163
+ resharper_web_config_wrong_module_highlighting = warning
164
+
165
+ [{*.har,*.inputactions,*.jsb2,*.jsb3,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,.ws-context,jest.config}]
166
+ indent_style = space
167
+ indent_size = 2
168
+
169
+ [{*.yaml,*.yml}]
170
+ indent_style = space
171
+ indent_size = 2
172
+
173
+ [*.asmdef]
174
+ indent_style = space
175
+ indent_size = 2
176
+
177
+ [*.asmref]
178
+ indent_style = space
179
+ indent_size = 2
180
+
181
+ [*.{appxmanifest,asax,ascx,aspx,axaml,blockshader,build,c,c++,c++m,cc,ccm,cginc,compute,cp,cpp,cppm,cs,cshtml,cu,cuh,cxx,cxxm,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,h++,hh,hlsl,hlsli,hlslinc,hp,hpp,hxx,icc,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,mxx,nuspec,paml,razor,resw,resx,shader,shaderFoundry,skin,tcc,tpp,urtshader,usf,ush,uxml,vb,xaml,xamlx,xoml,xsd}]
182
+ indent_style = space
183
+ indent_size = 4
184
+ tab_width = 4
@@ -0,0 +1,22 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: dotnet-tool-restore
5
+ name: Install .NET tools
6
+ entry: dotnet tool restore
7
+ language: system
8
+ always_run: true
9
+ pass_filenames: false
10
+ stages:
11
+ - pre-commit
12
+ - pre-push
13
+ - post-checkout
14
+ - post-rewrite
15
+ description: Install the .NET tools listed at .config/dotnet-tools.json.
16
+ - id: csharpier
17
+ name: Run CSharpier on C# files
18
+ entry: dotnet tool run dotnet-csharpier
19
+ language: system
20
+ types:
21
+ - c#
22
+ description: CSharpier is an opinionated C# formatter inspired by Prettier.
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 9e450a3f92f4be74da41959260563827
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -58,8 +58,11 @@ namespace DxMessaging.Editor
58
58
  continue;
59
59
  }
60
60
 
61
- string dllName = Path.GetFileName(dllPath);
62
- dllNames.Add(dllName);
61
+ if (!dllPath.Contains("Assets/Plugins/WallstopStudios.DxMessaging"))
62
+ {
63
+ string dllName = Path.GetFileName(dllPath);
64
+ dllNames.Add(dllName);
65
+ }
63
66
  }
64
67
 
65
68
  string[] dllRelativeDirectories = { LibraryPathRelative, AnalyzerPathRelative };
@@ -85,13 +88,31 @@ namespace DxMessaging.Editor
85
88
  const string pluginsDirectory =
86
89
  "Assets/Plugins/WallstopStudios.DxMessaging/";
87
90
  string outputAsset = $"{pluginsDirectory}{requiredDllName}";
91
+ string sourceAsset = $"{relativeDirectory}{requiredDllName}";
88
92
  Directory.CreateDirectory(pluginsDirectory);
89
93
  if (!File.Exists(outputAsset))
90
94
  {
91
- File.Copy($"{relativeDirectory}{requiredDllName}", outputAsset);
95
+ File.Copy(sourceAsset, outputAsset);
92
96
  AssetDatabase.ImportAsset(outputAsset);
93
97
  found = true;
94
98
  }
99
+ else
100
+ {
101
+ FileInfo sourceInfo = new(sourceAsset);
102
+ FileInfo destInfo = new(outputAsset);
103
+
104
+ if (destInfo.LastWriteTime < sourceInfo.LastWriteTime)
105
+ {
106
+ // Source file is newer, so copy the file (overwrite destination)
107
+ File.Copy(sourceAsset, outputAsset, true);
108
+ AssetDatabase.ImportAsset(outputAsset);
109
+ found = true;
110
+ }
111
+ else
112
+ {
113
+ continue;
114
+ }
115
+ }
95
116
 
96
117
  if (requiredDllName == SourceGeneratorDllName)
97
118
  {
@@ -120,10 +141,6 @@ namespace DxMessaging.Editor
120
141
  }
121
142
 
122
143
  anyFound |= found;
123
- Debug.Log(
124
- $"Missing required dll '{requiredDllName}', "
125
- + $"{(found ? "creation successful." : "WARNING! Manual creation required.")}"
126
- );
127
144
  }
128
145
 
129
146
  if (anyFound)
package/README.md CHANGED
@@ -36,16 +36,16 @@ Grab a copy of this repo (either `git clone` both [this repo](https://github.com
36
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
37
 
38
38
  # Benchmarks
39
- DxMessaging is currently a bit slower (2-3x) than Unity's built in messaging solution (when running in Unity). [Source](./Tests/Runtime/Benchmarks/PerformanceTests.cs).
39
+ 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
40
 
41
41
  | Message Tech | Operations / Second | Allocations? |
42
42
  | ------------ | ------------------- | ------------ |
43
- | Unity | 2,287,562 | Yes |
44
- | DxMessaging (GameObject) - Normal | 1,198,797 | No |
45
- | DxMessaging (Component) - Normal | 1,198,796 | No |
46
- | DxMessaging (GameObject) - No-Copy | 1,137,634 | No |
47
- | DxMessaging (Component) - No-Copy | 1,225,105 | No |
48
- | DxMessaging (Untargeted) - No-Copy | 1,681,407 | No |
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 |
49
49
 
50
50
  # Functionality
51
51
  While not as fast, DxMessaging offers *additional functionality* as compared to Unity's messaging solution.
@@ -121,16 +121,6 @@ public partial struct SimpleUntargetedMessage // No longer needed : IUntargetedM
121
121
  }
122
122
  ```
123
123
 
124
- Or, if you already have messages, you can leave the interface implementations as-is and get a no-boxing implementation with the `DxAutoMessageType` attribute. `partial` is still required.
125
-
126
- To use:
127
- ```csharp
128
- [DxAutoMessageType]
129
- public partial struct SimpleTargetedMessage : ITargetedMessage<SimpleTargetedMessage>
130
- {
131
- }
132
- ```
133
-
134
124
  ## Integration
135
125
  See the [tests](./Tests/Runtime/Scripts/) directory for examples about how to integrate with the MessageAwareComponent. But, for some starters:
136
126
  ```csharp
@@ -2,6 +2,10 @@
2
2
  {
3
3
  using System;
4
4
 
5
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
5
+ [AttributeUsage(
6
+ AttributeTargets.Class | AttributeTargets.Struct,
7
+ Inherited = false,
8
+ AllowMultiple = false
9
+ )]
6
10
  public sealed class DxBroadcastMessageAttribute : Attribute { }
7
11
  }
@@ -2,6 +2,10 @@
2
2
  {
3
3
  using System;
4
4
 
5
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
5
+ [AttributeUsage(
6
+ AttributeTargets.Class | AttributeTargets.Struct,
7
+ Inherited = false,
8
+ AllowMultiple = false
9
+ )]
6
10
  public sealed class DxTargetedMessageAttribute : Attribute { }
7
11
  }
@@ -2,6 +2,10 @@
2
2
  {
3
3
  using System;
4
4
 
5
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
5
+ [AttributeUsage(
6
+ AttributeTargets.Class | AttributeTargets.Struct,
7
+ Inherited = false,
8
+ AllowMultiple = false
9
+ )]
6
10
  public sealed class DxUntargetedMessageAttribute : Attribute { }
7
11
  }
@@ -8,5 +8,18 @@
8
8
  public interface IMessage
9
9
  {
10
10
  Type MessageType => GetType();
11
+
12
+ /// <summary>
13
+ /// Gets the optimized, unique integer ID for this message type, if available.
14
+ /// Returns null if this type uses the fallback mechanism (e.g., due to a compile-time
15
+ /// hash collision or manual implementation without an assigned ID).
16
+ /// </summary>
17
+ /// <remarks>
18
+ /// The ID is generated at compile-time for attributed types and is stable
19
+ /// across builds assuming the type's fully qualified name does not change.
20
+ /// It facilitates faster dictionary lookups compared to using System.Type directly.
21
+ /// Check for HasValue before using the Value.
22
+ /// </remarks>
23
+ int? OptimizedMessageId => null;
11
24
  }
12
25
  }
@@ -46,22 +46,12 @@
46
46
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
47
47
  public static implicit operator InstanceId(UnityEngine.GameObject gameObject)
48
48
  {
49
- if (gameObject == null)
50
- {
51
- throw new ArgumentNullException(nameof(gameObject));
52
- }
53
-
54
49
  return new InstanceId(gameObject);
55
50
  }
56
51
 
57
52
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
58
53
  public static implicit operator InstanceId(UnityEngine.Component component)
59
54
  {
60
- if (component == null)
61
- {
62
- throw new ArgumentNullException(nameof(component));
63
- }
64
-
65
55
  return new InstanceId(component);
66
56
  }
67
57
  #endif
@@ -98,37 +88,37 @@
98
88
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
99
89
  public static bool operator ==(InstanceId lhs, InstanceId rhs)
100
90
  {
101
- return lhs.Equals(rhs);
91
+ return lhs._id == rhs._id;
102
92
  }
103
93
 
104
94
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
105
95
  public static bool operator !=(InstanceId lhs, InstanceId rhs)
106
96
  {
107
- return !lhs.Equals(rhs);
97
+ return lhs._id != rhs._id;
108
98
  }
109
99
 
110
100
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
111
101
  public static bool operator <(InstanceId lhs, InstanceId rhs)
112
102
  {
113
- return lhs.CompareTo(rhs) < 0;
103
+ return lhs._id.CompareTo(rhs._id) < 0;
114
104
  }
115
105
 
116
106
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
117
107
  public static bool operator <=(InstanceId lhs, InstanceId rhs)
118
108
  {
119
- return lhs.CompareTo(rhs) <= 0;
109
+ return lhs._id.CompareTo(rhs._id) <= 0;
120
110
  }
121
111
 
122
112
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
123
113
  public static bool operator >(InstanceId lhs, InstanceId rhs)
124
114
  {
125
- return lhs.CompareTo(rhs) > 0;
115
+ return lhs._id.CompareTo(rhs._id) > 0;
126
116
  }
127
117
 
128
118
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
129
119
  public static bool operator >=(InstanceId lhs, InstanceId rhs)
130
120
  {
131
- return lhs.CompareTo(rhs) >= 0;
121
+ return lhs._id.CompareTo(rhs._id) >= 0;
132
122
  }
133
123
 
134
124
  [MethodImpl(MethodImplOptions.AggressiveInlining)]