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.
- package/.config/dotnet-tools.json +10 -0
- package/.editorconfig +184 -0
- package/.pre-commit-config.yaml +22 -0
- package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
- package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.pdb.meta +7 -0
- package/Editor/SetupCscRsp.cs +24 -7
- package/README.md +7 -17
- package/Runtime/Core/Attributes/DxBroadcastMessageAttribute.cs +5 -1
- package/Runtime/Core/Attributes/DxTargetedMessageAttribute.cs +5 -1
- package/Runtime/Core/Attributes/DxUntargetedMessageAttribute.cs +5 -1
- package/Runtime/Core/IMessage.cs +13 -0
- package/Runtime/Core/InstanceId.cs +6 -16
- package/Runtime/Core/MessageBus/MessageBus.cs +1751 -828
- package/Runtime/Core/MessageHandler.cs +408 -292
- package/Runtime/Unity/MessageAwareComponent.cs +0 -1
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +445 -0
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs.meta +3 -0
- package/Tests/Runtime/Benchmarks/PerformanceTests.cs +41 -26
- package/Tests/Runtime/Scripts/Components/GenericMessageAwareComponent.cs +19 -0
- package/Tests/Runtime/Scripts/Components/GenericMessageAwareComponent.cs.meta +3 -0
- package/Tests/Runtime/Scripts/Messages/GenericUntargetedMessage.cs +7 -0
- package/Tests/Runtime/Scripts/Messages/GenericUntargetedMessage.cs.meta +3 -0
- package/package.json +2 -2
- package/Runtime/Core/Attributes/DxAutoMessageTypeAttribute.cs +0 -7
- package/Runtime/Core/Attributes/DxAutoMessageTypeAttribute.cs.meta +0 -3
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoMessageTypeGenerator.cs +0 -92
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoMessageTypeGenerator.cs.meta +0 -11
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxBroadcastMessageGenerator.cs +0 -94
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxBroadcastMessageGenerator.cs.meta +0 -3
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxTargetedMessageGenerator.cs +0 -94
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxTargetedMessageGenerator.cs.meta +0 -3
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxUntargetedMessageGenerator.cs +0 -94
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxUntargetedMessageGenerator.cs.meta +0 -3
package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoMessageTypeGenerator.cs
DELETED
|
@@ -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
|
-
}
|
package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxBroadcastMessageGenerator.cs
DELETED
|
@@ -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
|
-
}
|
package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxTargetedMessageGenerator.cs
DELETED
|
@@ -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,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
|
-
}
|