com.wallstop-studios.dxmessaging 1.0.6 → 2.0.0-rc01

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 (50) hide show
  1. package/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  2. package/Analyzers/Microsoft.CodeAnalysis.dll.meta +33 -0
  3. package/Analyzers/Microsoft.CodeAnalysis.pdb.meta +7 -0
  4. package/Analyzers/Microsoft.CodeAnalysis.xml +38823 -0
  5. package/Analyzers/Microsoft.CodeAnalysis.xml.meta +7 -0
  6. package/Analyzers/System.Reflection.Metadata.dll +0 -0
  7. package/Analyzers/System.Reflection.Metadata.dll.meta +33 -0
  8. package/Analyzers/System.Reflection.Metadata.xml +8202 -0
  9. package/Analyzers/System.Reflection.Metadata.xml.meta +7 -0
  10. package/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.deps.json +319 -0
  11. package/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.deps.json.meta +7 -0
  12. package/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  13. package/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +69 -0
  14. package/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.pdb.meta +7 -0
  15. package/Analyzers.meta +8 -0
  16. package/Editor/SetupCscRsp.cs +67 -0
  17. package/Editor/SetupCscRsp.cs.meta +3 -0
  18. package/Editor/WallstopStudios.DxMessaging.Editor.asmdef +21 -0
  19. package/Editor/WallstopStudios.DxMessaging.Editor.asmdef.meta +7 -0
  20. package/README.md +43 -6
  21. package/Runtime/Core/Attributes/DxAutoMessageTypeAttribute.cs +9 -0
  22. package/Runtime/Core/Attributes/DxAutoMessageTypeAttribute.cs.meta +3 -0
  23. package/Runtime/Core/Attributes/DxBroadcastMessageAttribute.cs +10 -0
  24. package/Runtime/Core/Attributes/DxBroadcastMessageAttribute.cs.meta +3 -0
  25. package/Runtime/Core/Attributes/DxTargetedMessageAttribute.cs +10 -0
  26. package/Runtime/Core/Attributes/DxTargetedMessageAttribute.cs.meta +3 -0
  27. package/Runtime/Core/Attributes/DxUntargetedMessageAttribute.cs +10 -0
  28. package/Runtime/Core/Attributes/DxUntargetedMessageAttribute.cs.meta +3 -0
  29. package/Runtime/Core/Attributes.meta +3 -0
  30. package/Runtime/WallstopStudios.DxMessaging.asmdef +15 -17
  31. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoMessageTypeGenerator.cs +75 -0
  32. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoMessageTypeGenerator.cs.meta +11 -0
  33. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxBroadcastMessageGenerator.cs +77 -0
  34. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxBroadcastMessageGenerator.cs.meta +3 -0
  35. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxTargetedMessageGenerator.cs +77 -0
  36. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxTargetedMessageGenerator.cs.meta +3 -0
  37. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxUntargetedMessageGenerator.cs +78 -0
  38. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxUntargetedMessageGenerator.cs.meta +3 -0
  39. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +21 -0
  40. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj.meta +7 -0
  41. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.meta +8 -0
  42. package/SourceGenerators.meta +8 -0
  43. package/Tests/Runtime/Core/NominalTests.cs +127 -77
  44. package/Tests/Runtime/Core/RegistrationTests.cs +56 -106
  45. package/Tests/Runtime/Scripts/Messages/ComplexTargetedMessage.cs +4 -2
  46. package/Tests/Runtime/Scripts/Messages/SimpleBroadcastMessage.cs +3 -3
  47. package/Tests/Runtime/Scripts/Messages/SimpleTargetedMessage.cs +4 -4
  48. package/Tests/Runtime/Scripts/Messages/SimpleUntargetedMessage.cs +3 -3
  49. package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.asmdef +21 -21
  50. package/package.json +3 -3
@@ -1,18 +1,16 @@
1
- {
2
- "name": "WallstopStudios.DxMessaging",
3
- "rootNamespace": "DxMessaging",
4
- "references": [],
5
- "includePlatforms": [],
6
- "excludePlatforms": [],
7
- "allowUnsafeCode": false,
8
- "overrideReferences": true,
9
- "precompiledReferences": [
10
- "System.Runtime.CompilerServices.Unsafe.dll"
11
- ],
12
- "autoReferenced": true,
13
- "defineConstraints": [
14
- "UNITY_2017_1_OR_NEWER"
15
- ],
16
- "versionDefines": [],
17
- "noEngineReferences": false
1
+ {
2
+ "name": "WallstopStudios.DxMessaging",
3
+ "rootNamespace": "DxMessaging",
4
+ "references": [],
5
+ "includePlatforms": [],
6
+ "excludePlatforms": [],
7
+ "allowUnsafeCode": false,
8
+ "overrideReferences": true,
9
+ "precompiledReferences": [
10
+ "System.Runtime.CompilerServices.Unsafe.dll"
11
+ ],
12
+ "autoReferenced": true,
13
+ "defineConstraints": [],
14
+ "versionDefines": [],
15
+ "noEngineReferences": false
18
16
  }
@@ -0,0 +1,75 @@
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("DxMessaging.Core.Attributes.DxAutoMessageTypeAttribute");
27
+
28
+ foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
29
+ {
30
+ SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
31
+ ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
32
+
33
+ if (classSymbol.GetAttributes().Any(
34
+ attributeData => attributeData.AttributeClass.Equals(
35
+ attributeSymbol, SymbolEqualityComparer.Default)))
36
+ {
37
+ string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
38
+ string className = classSymbol.Name;
39
+ string typeKind = classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
40
+
41
+ string source = $$"""
42
+
43
+ namespace {{namespaceName}}
44
+ {
45
+ public partial {{typeKind}} {{className}}
46
+ {
47
+ public System.Type MessageType => typeof({{className}});
48
+ }
49
+ }
50
+
51
+ """;
52
+
53
+ context.AddSource($"{className}_DxAutoMessageType.g.cs", SourceText.From(source, Encoding.UTF8));
54
+ }
55
+ }
56
+ }
57
+
58
+ private sealed class SyntaxReceiver : ISyntaxReceiver
59
+ {
60
+ public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
61
+
62
+ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
63
+ {
64
+ if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
65
+ {
66
+ if (typeDeclarationSyntax.AttributeLists.Count > 0 &&
67
+ (typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration ||
68
+ typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration))
69
+ {
70
+ CandidateClasses.Add(typeDeclarationSyntax);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,11 @@
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:
@@ -0,0 +1,77 @@
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("DxMessaging.Core.Attributes.DxBroadcastMessageAttribute");
27
+
28
+ foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
29
+ {
30
+ SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
31
+ ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
32
+
33
+ if (classSymbol.GetAttributes().Any(
34
+ attributeData => attributeData.AttributeClass.Equals(
35
+ attributeSymbol, SymbolEqualityComparer.Default)))
36
+ {
37
+ string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
38
+ string className = classSymbol.Name;
39
+ string typeKind = classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
40
+
41
+ string source = $$"""
42
+
43
+ namespace {{namespaceName}}
44
+ {
45
+ using DxMessaging.Core.Messages;
46
+
47
+ public partial {{typeKind}} {{className}} : IBroadcastMessage
48
+ {
49
+ public System.Type MessageType => typeof({{className}});
50
+ }
51
+ }
52
+
53
+ """;
54
+
55
+ context.AddSource($"{className}_DxBroadcastMessage.g.cs", SourceText.From(source, Encoding.UTF8));
56
+ }
57
+ }
58
+ }
59
+
60
+ private sealed class SyntaxReceiver : ISyntaxReceiver
61
+ {
62
+ public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
63
+
64
+ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
65
+ {
66
+ if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
67
+ {
68
+ if (typeDeclarationSyntax.AttributeLists.Count > 0 &&
69
+ (typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration ||
70
+ typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration))
71
+ {
72
+ CandidateClasses.Add(typeDeclarationSyntax);
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 9f20e167b1f4496cae198016fa738fe1
3
+ timeCreated: 1730836618
@@ -0,0 +1,77 @@
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("DxMessaging.Core.Attributes.DxTargetedMessageAttribute");
27
+
28
+ foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
29
+ {
30
+ SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
31
+ ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
32
+
33
+ if (classSymbol.GetAttributes().Any(
34
+ attributeData => attributeData.AttributeClass.Equals(
35
+ attributeSymbol, SymbolEqualityComparer.Default)))
36
+ {
37
+ string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
38
+ string className = classSymbol.Name;
39
+ string typeKind = classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
40
+
41
+ string source = $$"""
42
+
43
+ namespace {{namespaceName}}
44
+ {
45
+ using DxMessaging.Core.Messages;
46
+
47
+ public partial {{typeKind}} {{className}} : ITargetedMessage
48
+ {
49
+ public System.Type MessageType => typeof({{className}});
50
+ }
51
+ }
52
+
53
+ """;
54
+
55
+ context.AddSource($"{className}_DxTargetedMessage.g.cs", SourceText.From(source, Encoding.UTF8));
56
+ }
57
+ }
58
+ }
59
+
60
+ private sealed class SyntaxReceiver : ISyntaxReceiver
61
+ {
62
+ public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
63
+
64
+ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
65
+ {
66
+ if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
67
+ {
68
+ if (typeDeclarationSyntax.AttributeLists.Count > 0 &&
69
+ (typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration ||
70
+ typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration))
71
+ {
72
+ CandidateClasses.Add(typeDeclarationSyntax);
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: d2d62958607d4a9284c0151e3ab03806
3
+ timeCreated: 1730836745
@@ -0,0 +1,78 @@
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("DxMessaging.Core.Attributes.DxUntargetedMessageAttribute");
27
+
28
+ foreach (TypeDeclarationSyntax classDeclaration in receiver.CandidateClasses)
29
+ {
30
+ SemanticModel model = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
31
+ ISymbol classSymbol = ModelExtensions.GetDeclaredSymbol(model, classDeclaration);
32
+
33
+ if (classSymbol.GetAttributes().Any(
34
+ attributeData => attributeData.AttributeClass.Equals(
35
+ attributeSymbol, SymbolEqualityComparer.Default)))
36
+ {
37
+ string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
38
+ string className = classSymbol.Name;
39
+ string typeKind = classDeclaration.Kind() == SyntaxKind.ClassDeclaration ? "class" : "struct";
40
+
41
+ string source = $$"""
42
+
43
+ namespace {{namespaceName}}
44
+ {
45
+ using DxMessaging.Core.Messages;
46
+
47
+ public partial {{typeKind}} {{className}} : IUntargetedMessage
48
+ {
49
+ public System.Type MessageType => typeof({{className}});
50
+ }
51
+ }
52
+
53
+ """;
54
+
55
+ context.AddSource($"{className}_DxUntargetedMessage.g.cs", SourceText.From(source, Encoding.UTF8));
56
+ }
57
+ }
58
+ }
59
+
60
+ private sealed class SyntaxReceiver : ISyntaxReceiver
61
+ {
62
+ public List<TypeDeclarationSyntax> CandidateClasses { get; } = [];
63
+
64
+ public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
65
+ {
66
+ if (syntaxNode is TypeDeclarationSyntax typeDeclarationSyntax)
67
+ {
68
+ if (typeDeclarationSyntax.AttributeLists.Count > 0 &&
69
+ (typeDeclarationSyntax.Kind() == SyntaxKind.ClassDeclaration ||
70
+ typeDeclarationSyntax.Kind() == SyntaxKind.StructDeclaration))
71
+ {
72
+ CandidateClasses.Add(typeDeclarationSyntax);
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: d0d88616d75247aab6b3a78bc8078418
3
+ timeCreated: 1730836844
@@ -0,0 +1,21 @@
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>netstandard2.0</TargetFramework>
5
+ <LangVersion>latest</LangVersion>
6
+ </PropertyGroup>
7
+
8
+ <ItemGroup>
9
+ <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.1">
10
+ <PrivateAssets>all</PrivateAssets>
11
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
12
+ </PackageReference>
13
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0">
14
+ <PrivateAssets>all</PrivateAssets>
15
+ </PackageReference>
16
+ <PackageReference Include="System.Collections.Immutable" Version="5.0.0">
17
+ <PrivateAssets>all</PrivateAssets>
18
+ </PackageReference>
19
+ </ItemGroup>
20
+
21
+ </Project>
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: e4915fed9609ee64f9cbdaaf0324b3d0
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: c7573be5899a5694398fa600a0bcd7b1
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: d606141670307c245b7a3726659948e6
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant: