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
@@ -1,92 +0,0 @@
1
- namespace WallstopStudios.DxMessaging.SourceGenerators;
2
-
3
- using System.Collections.Generic;
4
- using System.Linq;
5
- using System.Text;
6
- using Microsoft.CodeAnalysis;
7
- using Microsoft.CodeAnalysis.CSharp;
8
- using Microsoft.CodeAnalysis.CSharp.Syntax;
9
- using Microsoft.CodeAnalysis.Text;
10
-
11
- [Generator]
12
- public sealed class DxAutoMessageTypeGenerator : ISourceGenerator
13
- {
14
- public void Initialize(GeneratorInitializationContext context)
15
- {
16
- context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
17
- }
18
-
19
- public void Execute(GeneratorExecutionContext context)
20
- {
21
- if (context.SyntaxReceiver is not SyntaxReceiver receiver)
22
- {
23
- return;
24
- }
25
-
26
- INamedTypeSymbol attributeSymbol = context.Compilation.GetTypeByMetadataName(
27
- "DxMessaging.Core.Attributes.DxAutoMessageTypeAttribute"
28
- );
29
-
30
- foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
31
- {
32
- SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
33
- ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
34
-
35
- if (
36
- classSymbol
37
- .GetAttributes()
38
- .Any(attributeData =>
39
- attributeData.AttributeClass.Equals(
40
- attributeSymbol,
41
- SymbolEqualityComparer.Default
42
- )
43
- )
44
- )
45
- {
46
- string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
47
- string className = classSymbol.Name;
48
- string typeKind =
49
- classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
50
-
51
- string source = $$"""
52
-
53
- namespace {{namespaceName}}
54
- {
55
- public partial {{typeKind}} {{className}}
56
- {
57
- public System.Type MessageType => typeof({{className}});
58
- }
59
- }
60
-
61
- """;
62
-
63
- context.AddSource(
64
- $"{className}_DxAutoMessageType.g.cs",
65
- SourceText.From(source, Encoding.UTF8)
66
- );
67
- }
68
- }
69
- }
70
-
71
- private sealed class SyntaxReceiver : ISyntaxReceiver
72
- {
73
- public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
74
-
75
- public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
76
- {
77
- if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
78
- {
79
- if (
80
- typeDeclarationSyntax.AttributeLists.Count > 0
81
- && (
82
- typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration
83
- || typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration
84
- )
85
- )
86
- {
87
- CandidateClasses.Add(typeDeclarationSyntax);
88
- }
89
- }
90
- }
91
- }
92
- }
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: f6d3fd5024b56ce48b255e4d9b802b3b
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
@@ -1,94 +0,0 @@
1
- namespace WallstopStudios.DxMessaging.SourceGenerators;
2
-
3
- using System.Collections.Generic;
4
- using System.Linq;
5
- using System.Text;
6
- using Microsoft.CodeAnalysis;
7
- using Microsoft.CodeAnalysis.CSharp;
8
- using Microsoft.CodeAnalysis.CSharp.Syntax;
9
- using Microsoft.CodeAnalysis.Text;
10
-
11
- [Generator]
12
- public sealed class DxBroadcastMessageGenerator : ISourceGenerator
13
- {
14
- public void Initialize(GeneratorInitializationContext context)
15
- {
16
- context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
17
- }
18
-
19
- public void Execute(GeneratorExecutionContext context)
20
- {
21
- if (context.SyntaxReceiver is not SyntaxReceiver receiver)
22
- {
23
- return;
24
- }
25
-
26
- INamedTypeSymbol attributeSymbol = context.Compilation.GetTypeByMetadataName(
27
- "DxMessaging.Core.Attributes.DxBroadcastMessageAttribute"
28
- );
29
-
30
- foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
31
- {
32
- SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
33
- ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
34
-
35
- if (
36
- classSymbol
37
- .GetAttributes()
38
- .Any(attributeData =>
39
- attributeData.AttributeClass.Equals(
40
- attributeSymbol,
41
- SymbolEqualityComparer.Default
42
- )
43
- )
44
- )
45
- {
46
- string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
47
- string className = classSymbol.Name;
48
- string typeKind =
49
- classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
50
-
51
- string source = $$"""
52
-
53
- namespace {{namespaceName}}
54
- {
55
- using DxMessaging.Core.Messages;
56
-
57
- public partial {{typeKind}} {{className}} : IBroadcastMessage
58
- {
59
- public System.Type MessageType => typeof({{className}});
60
- }
61
- }
62
-
63
- """;
64
-
65
- context.AddSource(
66
- $"{className}_DxBroadcastMessage.g.cs",
67
- SourceText.From(source, Encoding.UTF8)
68
- );
69
- }
70
- }
71
- }
72
-
73
- private sealed class SyntaxReceiver : ISyntaxReceiver
74
- {
75
- public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
76
-
77
- public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
78
- {
79
- if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
80
- {
81
- if (
82
- typeDeclarationSyntax.AttributeLists.Count > 0
83
- && (
84
- typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration
85
- || typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration
86
- )
87
- )
88
- {
89
- CandidateClasses.Add(typeDeclarationSyntax);
90
- }
91
- }
92
- }
93
- }
94
- }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 9f20e167b1f4496cae198016fa738fe1
3
- timeCreated: 1730836618
@@ -1,94 +0,0 @@
1
- namespace WallstopStudios.DxMessaging.SourceGenerators;
2
-
3
- using System.Collections.Generic;
4
- using System.Linq;
5
- using System.Text;
6
- using Microsoft.CodeAnalysis;
7
- using Microsoft.CodeAnalysis.CSharp;
8
- using Microsoft.CodeAnalysis.CSharp.Syntax;
9
- using Microsoft.CodeAnalysis.Text;
10
-
11
- [Generator]
12
- public sealed class DxTargetedMessageGenerator : ISourceGenerator
13
- {
14
- public void Initialize(GeneratorInitializationContext context)
15
- {
16
- context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
17
- }
18
-
19
- public void Execute(GeneratorExecutionContext context)
20
- {
21
- if (context.SyntaxReceiver is not SyntaxReceiver receiver)
22
- {
23
- return;
24
- }
25
-
26
- INamedTypeSymbol attributeSymbol = context.Compilation.GetTypeByMetadataName(
27
- "DxMessaging.Core.Attributes.DxTargetedMessageAttribute"
28
- );
29
-
30
- foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
31
- {
32
- SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
33
- ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
34
-
35
- if (
36
- classSymbol
37
- .GetAttributes()
38
- .Any(attributeData =>
39
- attributeData.AttributeClass.Equals(
40
- attributeSymbol,
41
- SymbolEqualityComparer.Default
42
- )
43
- )
44
- )
45
- {
46
- string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
47
- string className = classSymbol.Name;
48
- string typeKind =
49
- classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
50
-
51
- string source = $$"""
52
-
53
- namespace {{namespaceName}}
54
- {
55
- using DxMessaging.Core.Messages;
56
-
57
- public partial {{typeKind}} {{className}} : ITargetedMessage
58
- {
59
- public System.Type MessageType => typeof({{className}});
60
- }
61
- }
62
-
63
- """;
64
-
65
- context.AddSource(
66
- $"{className}_DxTargetedMessage.g.cs",
67
- SourceText.From(source, Encoding.UTF8)
68
- );
69
- }
70
- }
71
- }
72
-
73
- private sealed class SyntaxReceiver : ISyntaxReceiver
74
- {
75
- public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
76
-
77
- public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
78
- {
79
- if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
80
- {
81
- if (
82
- typeDeclarationSyntax.AttributeLists.Count > 0
83
- && (
84
- typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration
85
- || typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration
86
- )
87
- )
88
- {
89
- CandidateClasses.Add(typeDeclarationSyntax);
90
- }
91
- }
92
- }
93
- }
94
- }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: d2d62958607d4a9284c0151e3ab03806
3
- timeCreated: 1730836745
@@ -1,94 +0,0 @@
1
- namespace WallstopStudios.DxMessaging.SourceGenerators;
2
-
3
- using System.Collections.Generic;
4
- using System.Linq;
5
- using System.Text;
6
- using Microsoft.CodeAnalysis;
7
- using Microsoft.CodeAnalysis.CSharp;
8
- using Microsoft.CodeAnalysis.CSharp.Syntax;
9
- using Microsoft.CodeAnalysis.Text;
10
-
11
- [Generator]
12
- public sealed class DxUntargetedMessageGenerator : ISourceGenerator
13
- {
14
- public void Initialize(GeneratorInitializationContext context)
15
- {
16
- context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
17
- }
18
-
19
- public void Execute(GeneratorExecutionContext context)
20
- {
21
- if (context.SyntaxReceiver is not SyntaxReceiver receiver)
22
- {
23
- return;
24
- }
25
-
26
- INamedTypeSymbol attributeSymbol = context.Compilation.GetTypeByMetadataName(
27
- "DxMessaging.Core.Attributes.DxUntargetedMessageAttribute"
28
- );
29
-
30
- foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
31
- {
32
- SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
33
- ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
34
-
35
- if (
36
- classSymbol
37
- .GetAttributes()
38
- .Any(attributeData =>
39
- attributeData.AttributeClass.Equals(
40
- attributeSymbol,
41
- SymbolEqualityComparer.Default
42
- )
43
- )
44
- )
45
- {
46
- string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
47
- string className = classSymbol.Name;
48
- string typeKind =
49
- classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
50
-
51
- string source = $$"""
52
-
53
- namespace {{namespaceName}}
54
- {
55
- using DxMessaging.Core.Messages;
56
-
57
- public partial {{typeKind}} {{className}} : IUntargetedMessage
58
- {
59
- public System.Type MessageType => typeof({{className}});
60
- }
61
- }
62
-
63
- """;
64
-
65
- context.AddSource(
66
- $"{className}_DxUntargetedMessage.g.cs",
67
- SourceText.From(source, Encoding.UTF8)
68
- );
69
- }
70
- }
71
- }
72
-
73
- private sealed class SyntaxReceiver : ISyntaxReceiver
74
- {
75
- public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
76
-
77
- public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
78
- {
79
- if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
80
- {
81
- if (
82
- typeDeclarationSyntax.AttributeLists.Count > 0
83
- && (
84
- typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration
85
- || typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration
86
- )
87
- )
88
- {
89
- CandidateClasses.Add(typeDeclarationSyntax);
90
- }
91
- }
92
- }
93
- }
94
- }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: d0d88616d75247aab6b3a78bc8078418
3
- timeCreated: 1730836844